import java.applet.AppletContext;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.URL;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Client extends Applet {
	private String consoleInput;
	public static boolean consoleOpen;
	private final String[] consoleMessages;
	private static boolean aBoolean993;
	private static int anInt1005;
	private static int anInt1051;
	private static int anInt1061;
	public static int scrollerPosition;
	private static int anInt1097;
	private static int anInt1117;
	private static int anInt1134;
	private static int anInt1142;
	private static int anInt1155;
	private static int anInt1175;
	private static int anInt1188;
	private static int anInt1226;
	private static int anInt1288;
	public static int anInt1290;
	private static int anInt849;
	private static int anInt854;
	private static int anInt924;
	private static int anInt986;
	private static final int[] anIntArray1019;
	static final int[] anIntArray1204 = { 9104, 10275, 7595, 3610, 7975, 8526, 918, 38802, 24466,
	10145, 58654, 5027, 1457, 16565, 34991, 25486 };
	public static int anIntArray1232[];
	static final int[][] anIntArrayArray1003 = {
	{ 6798, 107, 10283, 16, 4797, 7744, 5799, 4634, 33697, 22433, 2983, 54193 },
	{ 8741, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578,
	35003, 25239 },
	{ 25238, 8742, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341,
	16578, 35003 }, { 4626, 11146, 6439, 12, 4758, 10270 },
	{ 4550, 4537, 5681, 5673, 5790, 6806, 8076, 4574 } };
	private static boolean flagged;
	private static boolean fpsOn = false;
	public static boolean inputTaken;
	private static boolean isMembers = true;
	static int loopCycle;
	private static boolean lowMem;
	public static Player myPlayer;
	private static int nodeID = 10;
	static int portOff;
	private static final long serialVersionUID = 71247154817208696L;
	private static String server = "";
	private static int totalRead = 0;
	public int VERSION = 484;
	private static final String validUserPassChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";
	private IndexedSprite titleBox;
	private IndexedSprite titleButton;
	private IndexedSprite[] runes;
	private boolean consoleFirstOpened = false;
	private boolean aBoolean1017;
	private boolean aBoolean1031;
	private boolean aBoolean1047;
	private boolean aBoolean1080;
	private boolean aBoolean1141;
	private boolean aBoolean1149;
	private boolean aBoolean1159;
	private boolean aBoolean1160;
	private boolean aBoolean1242;
	private volatile boolean flameRequest;
	private boolean aBoolean848;
	private boolean aBoolean872;
	private boolean aBoolean954;
	private boolean aBoolean972;
	private final boolean aBoolean994;
	private final boolean[] aBooleanArray876;
	private byte[] destTexture;
	private byte[][] aByteArrayArray1183;
	private byte[][] aByteArrayArray1247;
	private CollisionMap[] collisionMap;
	private Deque projectileList;
	private Deque stillGraphicList;
	private Deque aClass19_1179;
	private Sprite leftFlame;
	private Sprite rightFlame;
	private Sprite aClass30_Sub2_Sub1_Sub1_931;
	private Sprite aClass30_Sub2_Sub1_Sub1_932;
	private Sprite[] aClass30_Sub2_Sub1_Sub1Array1140;
	public final Interface iComponent;
	private int activeInterfaceType;
	private long aLong1172;
	private long aLong1215;
	private long aLong1220;
	private long aLong824;
	private long aLong953;
	private String amountOrNameInput;
	private int anInt1009;
	private int anInt1010;
	private int anInt1011;
	private int anInt1014;
	private int anInt1015;
	private int anInt1016;
	private int anInt1018;
	private int anInt1021;
	private int anInt1022;
	private int anInt1026;
	private int anInt1036;
	private int anInt1037;
	private int anInt1039;
	private int anInt1040;
	private int anInt1041;
	public int anInt1044;
	private int anInt1046;
	private int anInt1048;
	private int anInt1054;
	private int anInt1055;
	private int anInt1062;
	private int anInt1069;
	private int anInt1070;
	private int anInt1071;
	private int loadingTextWidth;
	private int anInt1084;
	private int anInt1085;
	private int anInt1087;
	private int anInt1088;
	private int anInt1098;
	private int anInt1099;
	private int anInt1100;
	private int anInt1101;
	private int anInt1102;
	private int anInt1104;
	public int anInt1129;
	private int anInt1131;
	private int anInt1132;
	private int anInt1137;
	private int anInt1169;
	private int anInt1171;
	private int anInt1184;
	private int anInt1186;
	private int anInt1187;
	private int anInt1193;
	private int anInt1208;
	private int anInt1210;
	private int scrollerHeight;
	private int anInt1213;
	private int anInt1222;
	private int anInt1237;
	private int anInt1238;
	public final int anInt1239 = 100;
	private int anInt1249;
	private int anInt1251;
	private int anInt1253;
	private int anInt1254;
	private int anInt1257;
	private int anInt1264;
	private int anInt1265;
	private int anInt1268;
	private int anInt1269;
	private int anInt1275;
	private int anInt1278;
	private int anInt1279;
	private int anInt1283;
	private int anInt1284;
	private int anInt1285;
	private int anInt1289;
	public int anInt1315;
	public int anInt1500;
	public int anInt1501;
	private int anInt839;
	private int anInt841;
	private int anInt842;
	private int anInt843;
	private int anInt855;
	private int anInt874;
	private int anInt886;
	private int anInt893;
	private int anInt896;
	private int anInt897;
	private int anInt900;
	private int anInt913;
	private int anInt933;
	private int anInt934;
	private int anInt935;
	private int anInt936;
	private int anInt937;
	private int anInt938;
	private int anInt945;
	private final int anInt975;
	private int anInt984;
	private int anInt985;
	private int anInt988;
	private int anInt989;
	private int anInt995;
	private int anInt996;
	private int anInt997;
	private int anInt998;
	private int anInt999;
	private final int[] anIntArray1030;
	private final int[] anIntArray1045;
	private final int[] miniMapTrimLeft;
	private final int[] compassTrimRight;
	private final int[] anIntArray1065;
	private int[] anIntArray1072;
	private int[] anIntArray1073;
	private final int[] anIntArray1177 = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
	2, 2, 2, 3 };
	private int[] chatboxTexturePool;
	private int[] inventoryTexturePool;
	private int[] gameScreenTexturePool;
	private int[] anIntArray1190;
	private int[] anIntArray1191;
	private final int[] anIntArray1203;
	private final int[] anIntArray1207;
	private final int[] miniMapTrimRight;
	private int[] anIntArray1234;
	private int[] anIntArray1235;
	private int[] anIntArray1236;
	private final int[] anIntArray1240;
	private final int[] anIntArray1241;
	private final int[] anIntArray1250;
	private int[] anIntArray828;
	private int[] anIntArray829;
	private int[] anIntArray840;
	private int[] anIntArray850;
	private int[] anIntArray851;
	private int[] anIntArray852;
	private int[] anIntArray853;
	private final int[] anIntArray873;
	private int[] anIntArray894;
	private final int[] anIntArray928;
	private final int[] colors = { 0xffff00, 0xff0000, 0x00ff00, 0x00ffff, 0xff00ff, 0xffffff };
	private final int[] compassTrimLeft;
	private final int[] anIntArray969;
	private final int[] anIntArray976;
	private final int[] anIntArray977;
	private final int[] anIntArray978;
	private final int[] anIntArray979;
	private final int[] anIntArray980;
	private final int[] anIntArray981;
	private final int[] anIntArray982;
	private final int[] anIntArray990;
	private int[][] anIntArrayArray825;
	private int[][] anIntArrayArray901;
	private int[][] anIntArrayArray929;
	private final int[][][] anIntArrayArrayArray1129;
	private GraphicsBuffer topLeftCanvas;
	private GraphicsBuffer bottomLeftCanvas;
	private GraphicsBuffer leftCanvas;
	private GraphicsBuffer leftFlameCanvas;
	private GraphicsBuffer rightFlameCanvas;
	private GraphicsBuffer titleBoxLeftCanvas;
	private GraphicsBuffer bottomRightCanvas;
	private GraphicsBuffer smallLeftCanvas;
	private GraphicsBuffer smallRightCanvas;
	private GraphicsBuffer gameScreenCanvas;
	private java.net.Socket socket;
	private int assistMode;
	private Packet chatBuffers;
	private Packet settingsBuffers;
	private Packet[] playerAppearanceBuffers;
	private String loadingText;
	private final String[] entityOverheadChat;
	private int atInventoryIndex;
	private int atInventoryInterface;
	private int atInventoryInterfaceType;
	private int atInventoryLoopCycle;
	private final String[] atPlayerActions;
	private final boolean[] atPlayerArray;
	private int backDialogID;
	private int baseX;
	private int baseY;
	private int[] bigX;
	private int[] bigY;
	private Font boldText;
	private Packet outputStream;
	private byte[][][] byteGroundArray;
	private boolean canMute;
	private Sprite[] chatBox = new Sprite[4];
	private GraphicsBuffer chatboxCanvas;
	private int chatFilterHover = -1;
	private final String[] chatMessages;
	private final String[] chatNames;
	private final int[] chatRights;
	private final int[] chatTypes;
	private int chatTypeView;
	private int clanChatMode;
	public String clanName;
	private Sprite compass;
	private int consoleAlpha = 0;
	private String continueMessageTitle;
	private Sprite[] crosses;
	private int crossIndex;
	private int crossType;
	private int crossX;
	private int crossY;
	private final int[] currentExp;
	private int currentSong;
	private final int[] currentStats;
	private int daysSinceLastLogin;
	private int recoveriesLastSet;
	final FileStore[] cacheIndices;
	private int destX;
	private int destY;
	private int dialogID;
	public int drawCount;
	private volatile boolean drawFlames;
	private volatile boolean drawingFlames;
	private IsaacCipher encryption;
	private int playerEnergy;
	private final int[] expectedCRCs;
	private Sprite[] filterButtons = new Sprite[7];
	private long flashRate;
	private boolean flashRequest[] = new boolean[6];
	private int flashCount[] = { 5, 5, 5, 5, 5, 5 };
	private int friendsCount;
	private String[] friendsList;
	private int friendsListAction;
	private long[] friendsListAsLongs;
	private int[] friendsNodeIDs;
	public int fullscreenInterfaceID;
	public int[] fullScreenTexturePool;
	private boolean genericLoadingError;
	private Deque[][][] groundArray;
	private Sprite[] headIcons_hint;
	private Sprite[] headIcons_pk;
	private Sprite[] headIcons_prayer;
	private Sprite[] hitMarks;
	private Sprite[] newHitMarks = new Sprite[4];
	private int ignoreCount;
	private final long[] ignoreListAsLongs;
	private int inputDialogState;
	private String inputString;
	private Packet inputStream;
	private int[][][] averageTileHeight;
	private Sprite[] inventory = new Sprite[4];
	private GraphicsBuffer inventoryCanvas;
	private int invOverlayInterfaceID;
	private boolean isRunning = false;
	private int itemSelected;
	private int lastActiveInvInterface;
	private GraphicsBuffer leftFrame;
	private boolean loadingError;
	private int loadingStage;
	public static boolean loggedIn;
	private int loginFailures;
	private String loginMessage1;
	private String loginMessage2;
	private int loginScreenCursorPos;
	private int loginScreenState;
	private IndexedSprite roundMapBack;
	private Sprite[] worldMapGlobe = new Sprite[3];
	private Sprite[] mapBackground = new Sprite[4];
	private Sprite[] hoverStones = new Sprite[6];
	private Sprite mapDotFriend;
	private Sprite mapDotItem;
	private Sprite mapDotNPC;
	private Sprite mapDotPlayer;
	private Sprite mapDotTeam;
	private Sprite mapEdge;
	private Sprite mapFlag;
	private Sprite[] mapFunctions;
	private Sprite mapMarker;
	private IndexedSprite[] mapScenes;
	private final int maxPlayers;
	private final int[] maxStats;
	private int membersInt;
	private int[] menuActionCmd1;
	private int[] menuActionCmd2;
	private int[] menuActionCmd3;
	private int[] menuActionID;
	private String[] menuActionName;
	private int menuActionRow;
	private int menuHeight;
	private int menuOffsetX;
	private int menuOffsetY;
	private boolean menuOpen;
	/**
	 * Determines the menu offsets. Not used as we have context menus over
	 * gameframe.
	 */
	@SuppressWarnings("unused")
	private int menuScreenArea;
	private int menuWidth;
	public String message;
	private boolean messagePromptRaised;
	private String messagePromptTitle;
	private Sprite miniMap;
	/**
	 * The rotation of the minimap and compass.
	 * Decrease = rotate left.
	 */
	private int minimapAndCompassRotation;
	/**
	 * The rotation of the minimap itself.
	 * Decrease = rotate left.
	 */
	private int minimapRotation;
	/**
	 * The zoom on the minimap. Decrease to increase the zoom.
	 */
	private int minimapZoom;
	private GraphicsBuffer minimapCanvas;
	private final IndexedSprite[] modIcons;
	private MouseDetection mouseDetection;
	private int mouseInvInterfaceIndex;
	private boolean musicEnabled;
	private String myPassword;
	private final int myPlayerIndex;
	private int myPrivilege;
	private String myUsername;
	public String name;
	private boolean drawInventoryRequest;
	private boolean newTextDrawn[] = new boolean[6];
	private int nextSong;
	private Npc[] npcArray;
	private int npcCount;
	private int[] npcIndices;
	private OnDemandFetcher onDemandFetcher;
	private int openInterfaceID;
	private boolean pauseFlash[] = new boolean[6];
	private int packetSize;
	private int packetType;
	private Font plainText;
	private int plane;
	private Player[] playerArray;
	private int playerCount;
	private int[] playerIndices;
	private int prevSong;
	private int privateChatMode;
	private String promptInput;
	private int publicChatMode;
	private Sprite[] redStones = new Sprite[6];
	private String reportAbuseInput;
	private int reportAbuseInterfaceID;
	public int rights;
	private boolean rsAlreadyLoaded;
	private Sprite[] scrollBar = new Sprite[18];
	private String selectedItemName;
	private Sprite[] sideIcons = new Sprite[30];
	private Sprite[] logoutDoor = new Sprite[8];
	private Font smallText;
	private Socket socketStream;
	private boolean songChanging;
	private int spellSelected;
	private String spellTooltip;
	private int spellUsableOn;
	private int splitPrivateChat;
	private int spriteDrawX;
	private int spriteDrawY;
	private Sprite[] statusGlobes = new Sprite[32];
	private int statusGlobesHover = 0;
	private int doorHover = 0;
	private int worldMapHover = 0;
	private int inventoryHover = -1;
	private boolean inventoryAltered;
	private int tabID;
	private final int[] tabInterfaceIDs = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
	-1, -1, -1 };
	private Archive titleArchive;
	private GraphicsBuffer topFrame;
	private int tradeMode;
	private int unknownInt10;
	private int unreadMessages;
	public int variousSettings[];
	private int weight;
	private boolean welcomeScreenRaised;
	private SceneGraph sceneGraph;
	private int cameraYaw;
	private int xCameraPos;
	private int cameraPitch;
	private int yCameraPos;
	private int zCameraPos;
	static {
		anIntArray1019 = new int[99];
		int i = 0;
		for (int j = 0; j < 99; j++) {
			int l = j + 1;
			int i1 = (int) (l + 300D * Math.pow(2D, l / 7D));
			i += i1;
			Client.anIntArray1019[j] = i / 4;
		}
		Client.anIntArray1232 = new int[32];
		i = 2;
		for (int k = 0; k < 32; k++) {
			Client.anIntArray1232[k] = i - 1;
			i += i;
		}
	}

	private static String combatDifferenceColor(int i, int j) {
		int k = i - j;
		if (k < -9) {
			return "@red@";
		}
		if (k < -6) {
			return "@or3@";
		}
		if (k < -3) {
			return "@or2@";
		}
		if (k < 0) {
			return "@or1@";
		}
		if (k > 9) {
			return "@gre@";
		}
		if (k > 6) {
			return "@gr3@";
		}
		if (k > 3) {
			return "@gr2@";
		}
		if (k > 0) {
			return "@gr1@";
		} else {
			return "@yel@";
		}
	}

	public static String getFileNameWithoutExtension(String fileName) {
		File tmpFile = new File(fileName);
		tmpFile.getName();
		int whereDot = tmpFile.getName().lastIndexOf('.');
		if ((0 < whereDot) && (whereDot <= tmpFile.getName().length() - 2)) {
			return tmpFile.getName().substring(0, whereDot);
		}
		return "";
	}

	private static String formatValue(int value) {
		if (value < 100000) {
			return String.valueOf(value);
		}
		if (value < 10000000) {
			return value / 1000 + "K";
		} else {
			return value / 1000000 + "M";
		}
	}

	private static String getFormattedValue(int value) {
		String valueAsString = String.valueOf(value);
		for (int i = valueAsString.length() - 3; i > 0; i -= 3) {
			valueAsString = valueAsString.substring(0, i) + "," + valueAsString.substring(i);
		}
		if (valueAsString.length() > 8) {
			valueAsString = "@gre@" + valueAsString.substring(0, valueAsString.length() - 8)
			+ " million @whi@(" + valueAsString + ")";
		} else if (valueAsString.length() > 4) {
			valueAsString = "@cya@" + valueAsString.substring(0, valueAsString.length() - 4)
			+ "K @whi@(" + valueAsString + ")";
		}
		return " " + valueAsString;
	}

	public static void mainForJar(String args[]) {
		try {
			Client.nodeID = 10;
			Client.portOff = 0;
			Client.setHighMem();
			Client.isMembers = true;
			Signlink.storeid = 32;
			Signlink.startpriv(InetAddress.getLocalHost());
			Client client = new Client();
			client.createClientFrame(503, 765);
		} catch (Exception e) {
		}
	}

	public static void main(String args[]) {
		try {
			System.out.println("RS2 user client - release #" + 317);
			if (args.length != 5) {
				System.out
				.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid");
				return;
			}
			Client.nodeID = Integer.parseInt(args[0]);
			Client.portOff = Integer.parseInt(args[1]);
			if (args[2].equals("lowmem")) {
				Client.setLowMem();
			} else if (args[2].equals("highmem")) {
				Client.setHighMem();
			} else {
				System.out
				.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid");
				return;
			}
			if (args[3].equals("free")) {
				Client.isMembers = false;
			} else if (args[3].equals("members")) {
				Client.isMembers = true;
			} else {
				System.out
				.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid");
				return;
			}
			Signlink.storeid = Integer.parseInt(args[4]);
			Signlink.startpriv(InetAddress.getLocalHost());
			Client client = new Client();
			client.createClientFrame(503, 765);
		} catch (Exception exception) {
		}
	}

	public static final byte[] readFile(String name) {
		try {
			byte abyte0[];
			File file = new File(name);
			int i = (int) file.length();
			abyte0 = new byte[i];
			DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(
			new FileInputStream(name)));
			datainputstream.readFully(abyte0, 0, i);
			datainputstream.close();
			Client.totalRead++;
			return abyte0;
		} catch (Exception e) {
			System.out
			.println((new StringBuilder()).append("Read Error: ").append(name).toString());
			return null;
		}
	}

	private static void setHighMem() {
		SceneGraph.lowMem = false;
		Renderer3D.lowMem = false;
		Client.lowMem = false;
		Region.lowMem = false;
		ObjectDefinition.lowMem = false;
	}

	private static void setLowMem() {
		SceneGraph.lowMem = true;
		Renderer3D.lowMem = true;
		Client.lowMem = true;
		Region.lowMem = true;
		ObjectDefinition.lowMem = true;
	}

	private void addFriend(long l) {
		try {
			if (l == 0L) {
				return;
			}
			if ((friendsCount >= 100) && (anInt1046 != 1)) {
				pushMessage(
				"Your friendlist is full. Max of 100 for free users, and 200 for members", 0, "");
				return;
			}
			if (friendsCount >= 200) {
				pushMessage(
				"Your friendlist is full. Max of 100 for free users, and 200 for members", 0, "");
				return;
			}
			String s = TextUtil.fixName(TextUtil.nameForLong(l));
			for (int i = 0; i < friendsCount; i++) {
				if (friendsListAsLongs[i] == l) {
					pushMessage(s + " is already on your friend list", 0, "");
					return;
				}
			}
			for (int j = 0; j < ignoreCount; j++) {
				if (ignoreListAsLongs[j] == l) {
					pushMessage("Please remove " + s + " from your ignore list first", 0, "");
					return;
				}
			}
			if (s.equals(Client.myPlayer.name)) {
				return;
			} else {
				friendsList[friendsCount] = s;
				friendsListAsLongs[friendsCount] = l;
				friendsNodeIDs[friendsCount] = 0;
				friendsCount++;
				drawInventoryRequest = true;
				outputStream.putOperation(188);
				outputStream.putLong(l);
				return;
			}
		} catch (RuntimeException exception) {
			Signlink.reporterror("15283, " + (byte) 68 + ", " + l + ", " + exception.toString());
		}
		throw new RuntimeException();
	}

	private void addIgnore(long l) {
		try {
			if (l == 0L) {
				return;
			}
			if (ignoreCount >= 100) {
				pushMessage("Your ignore list is full. Max of 100 hit", 0, "");
				return;
			}
			String s = TextUtil.fixName(TextUtil.nameForLong(l));
			for (int j = 0; j < ignoreCount; j++) {
				if (ignoreListAsLongs[j] == l) {
					pushMessage(s + " is already on your ignore list", 0, "");
					return;
				}
			}
			for (int k = 0; k < friendsCount; k++) {
				if (friendsListAsLongs[k] == l) {
					pushMessage("Please remove " + s + " from your friend list first", 0, "");
					return;
				}
			}
			ignoreListAsLongs[ignoreCount++] = l;
			drawInventoryRequest = true;
			outputStream.putOperation(133);
			outputStream.putLong(l);
			return;
		} catch (RuntimeException runtimeexception) {
			Signlink.reporterror("45688, " + l + ", " + 4 + ", " + runtimeexception.toString());
		}
		throw new RuntimeException();
	}

	private void adjustVolume(boolean flag, int i) {
		Signlink.midivol = i;
		if (flag) {
			Signlink.midi = "voladjust";
		}
	}

	private void build3dScreenMenu() {
		if ((itemSelected == 0) && (spellSelected == 0)) {
			menuActionName[menuActionRow] = "Walk here";
			menuActionID[menuActionRow] = 516;
			menuActionCmd2[menuActionRow] = super.mouseX;
			menuActionCmd3[menuActionRow] = super.mouseY;
			menuActionRow++;
		}
		int j = -1;
		for (int k = 0; k < Model.anInt1687; k++) {
			int l = Model.anIntArray1688[k];
			int i1 = l & 0x7f;
			int j1 = l >> 7 & 0x7f;
			int k1 = l >> 29 & 3;
			int l1 = l >> 14 & 0x7fff;
			if (l == j) {
				continue;
			}
			j = l;
			if ((k1 == 2) && (sceneGraph.method304(plane, i1, j1, l) >= 0)) {
				ObjectDefinition objectDefinition = ObjectDefinition.forID(l1);
				if (objectDefinition.childrenIDs != null) {
					objectDefinition = objectDefinition.method580();
				}
				if (objectDefinition == null) {
					continue;
				}
				if (itemSelected == 1) {
					menuActionName[menuActionRow] = "Use " + selectedItemName + " with @cya@"
					+ objectDefinition.name;
					menuActionID[menuActionRow] = 62;
					menuActionCmd1[menuActionRow] = l;
					menuActionCmd2[menuActionRow] = i1;
					menuActionCmd3[menuActionRow] = j1;
					menuActionRow++;
				} else if (spellSelected == 1) {
					if ((spellUsableOn & 4) == 4) {
						menuActionName[menuActionRow] = spellTooltip + " @cya@"
						+ objectDefinition.name;
						menuActionID[menuActionRow] = 956;
						menuActionCmd1[menuActionRow] = l;
						menuActionCmd2[menuActionRow] = i1;
						menuActionCmd3[menuActionRow] = j1;
						menuActionRow++;
					}
				} else {
					if (objectDefinition.actions != null) {
						for (int i2 = 4; i2 >= 0; i2--) {
							if (objectDefinition.actions[i2] != null) {
								menuActionName[menuActionRow] = objectDefinition.actions[i2]
								+ " @cya@" + objectDefinition.name;
								if (i2 == 0) {
									menuActionID[menuActionRow] = 502;
								}
								if (i2 == 1) {
									menuActionID[menuActionRow] = 900;
								}
								if (i2 == 2) {
									menuActionID[menuActionRow] = 113;
								}
								if (i2 == 3) {
									menuActionID[menuActionRow] = 872;
								}
								if (i2 == 4) {
									menuActionID[menuActionRow] = 1062;
								}
								menuActionCmd1[menuActionRow] = l;
								menuActionCmd2[menuActionRow] = i1;
								menuActionCmd3[menuActionRow] = j1;
								menuActionRow++;
							}
						}
					}
					menuActionName[menuActionRow] = "Examine @cya@" + objectDefinition.name
					+ " @mag@(" + l1 + ") (" + (i1 + baseX) + "," + (j1 + baseY) + ")";
					// menuActionName[menuActionRow] = "Examine @cya@" + class46.name;
					menuActionID[menuActionRow] = 1226;
					menuActionCmd1[menuActionRow] = objectDefinition.type << 14;
					menuActionCmd2[menuActionRow] = i1;
					menuActionCmd3[menuActionRow] = j1;
					menuActionRow++;
				}
			}
			if (k1 == 1) {
				Npc npc1 = npcArray[l1];
				if ((npc1.desc.aByte68 == 1) && ((npc1.x & 0x7f) == 64) && ((npc1.y & 0x7f) == 64)) {
					for (int j2 = 0; j2 < npcCount; j2++) {
						Npc npc2 = npcArray[npcIndices[j2]];
						if ((npc2 != null) && (npc2 != npc1) && (npc2.desc.aByte68 == 1)
						&& (npc2.x == npc1.x) && (npc2.y == npc1.y)) {
							buildAtNPCMenu(npc2.desc, npcIndices[j2], j1, i1);
						}
					}
					for (int l2 = 0; l2 < playerCount; l2++) {
						Player player = playerArray[playerIndices[l2]];
						if ((player != null) && (player.x == npc1.x) && (player.y == npc1.y)) {
							buildAtPlayerMenu(i1, playerIndices[l2], player, j1);
						}
					}
				}
				buildAtNPCMenu(npc1.desc, l1, j1, i1);
			}
			if (k1 == 0) {
				Player player1 = playerArray[l1];
				if (((player1.x & 0x7f) == 64) && ((player1.y & 0x7f) == 64)) {
					for (int k2 = 0; k2 < npcCount; k2++) {
						Npc npc = npcArray[npcIndices[k2]];
						if ((npc != null) && (npc.desc.aByte68 == 1) && (npc.x == player1.x)
						&& (npc.y == player1.y)) {
							buildAtNPCMenu(npc.desc, npcIndices[k2], j1, i1);
						}
					}
					for (int i3 = 0; i3 < playerCount; i3++) {
						Player player2 = playerArray[playerIndices[i3]];
						if ((player2 != null) && (player2 != player1) && (player2.x == player1.x)
						&& (player2.y == player1.y)) {
							buildAtPlayerMenu(i1, playerIndices[i3], player2, j1);
						}
					}
				}
				buildAtPlayerMenu(i1, l1, player1, j1);
			}
			if (k1 == 3) {
				Deque groundItems = groundArray[plane][i1][j1];
				if (groundItems != null) {
					for (Item item = (Item) groundItems.getBack(); item != null; item = (Item) groundItems
					.getPrevious()) {
						ItemDefinition itemDefinition = ItemDefinition.forID(item.ID);
						if (itemSelected == 1) {
							menuActionName[menuActionRow] = "Use " + selectedItemName
							+ " with @lre@" + itemDefinition.name;
							menuActionID[menuActionRow] = 511;
							menuActionCmd1[menuActionRow] = item.ID;
							menuActionCmd2[menuActionRow] = i1;
							menuActionCmd3[menuActionRow] = j1;
							menuActionRow++;
						} else if (spellSelected == 1) {
							if ((spellUsableOn & 1) == 1) {
								menuActionName[menuActionRow] = spellTooltip + " @lre@"
								+ itemDefinition.name;
								menuActionID[menuActionRow] = 94;
								menuActionCmd1[menuActionRow] = item.ID;
								menuActionCmd2[menuActionRow] = i1;
								menuActionCmd3[menuActionRow] = j1;
								menuActionRow++;
							}
						} else {
							for (int j3 = 4; j3 >= 0; j3--) {
								if ((itemDefinition.groundActions != null)
								&& (itemDefinition.groundActions[j3] != null)) {
									menuActionName[menuActionRow] = itemDefinition.groundActions[j3]
									+ " @lre@" + itemDefinition.name;
									if (j3 == 0) {
										menuActionID[menuActionRow] = 652;
									}
									if (j3 == 1) {
										menuActionID[menuActionRow] = 567;
									}
									if (j3 == 2) {
										menuActionID[menuActionRow] = 234;
									}
									if (j3 == 3) {
										menuActionID[menuActionRow] = 244;
									}
									if (j3 == 4) {
										menuActionID[menuActionRow] = 213;
									}
									menuActionCmd1[menuActionRow] = item.ID;
									menuActionCmd2[menuActionRow] = i1;
									menuActionCmd3[menuActionRow] = j1;
									menuActionRow++;
								} else if (j3 == 2) {
									menuActionName[menuActionRow] = "Take @lre@"
									+ itemDefinition.name;
									menuActionID[menuActionRow] = 234;
									menuActionCmd1[menuActionRow] = item.ID;
									menuActionCmd2[menuActionRow] = i1;
									menuActionCmd3[menuActionRow] = j1;
									menuActionRow++;
								}
							}
							menuActionName[menuActionRow] = "Examine @lre@" + itemDefinition.name
							+ " @mag@(" + item.ID + ")";
							// menuActionName[menuActionRow] = "Examine @lre@" + itemDef.name;
							menuActionID[menuActionRow] = 1448;
							menuActionCmd1[menuActionRow] = item.ID;
							menuActionCmd2[menuActionRow] = i1;
							menuActionCmd3[menuActionRow] = j1;
							menuActionRow++;
						}
					}
				}
			}
		}
	}

	private void buildAtNPCMenu(EntityDefinition entity, int i, int j, int k) {
		if (menuActionRow >= 400) {
			return;
		}
		if (entity.childrenIDs != null) {
			entity = entity.method161();
		}
		if (entity == null) {
			return;
		}
		if (!entity.aBoolean84) {
			return;
		}
		String s = entity.name;
		if (entity.combatLevel != 0) {
			s = s + Client.combatDifferenceColor(Client.myPlayer.combatLevel, entity.combatLevel)
			+ " (level-" + entity.combatLevel + ")";
		}
		if (itemSelected == 1) {
			menuActionName[menuActionRow] = "Use " + selectedItemName + " with @yel@" + s;
			menuActionID[menuActionRow] = 582;
			menuActionCmd1[menuActionRow] = i;
			menuActionCmd2[menuActionRow] = k;
			menuActionCmd3[menuActionRow] = j;
			menuActionRow++;
			return;
		}
		if (spellSelected == 1) {
			if ((spellUsableOn & 2) == 2) {
				menuActionName[menuActionRow] = spellTooltip + " @yel@" + s;
				menuActionID[menuActionRow] = 413;
				menuActionCmd1[menuActionRow] = i;
				menuActionCmd2[menuActionRow] = k;
				menuActionCmd3[menuActionRow] = j;
				menuActionRow++;
			}
		} else {
			if (entity.actions != null) {
				for (int l = 4; l >= 0; l--) {
					if ((entity.actions[l] != null)
					&& !entity.actions[l].equalsIgnoreCase("attack")) {
						menuActionName[menuActionRow] = entity.actions[l] + " @yel@" + s;
						if (l == 0) {
							menuActionID[menuActionRow] = 20;
						}
						if (l == 1) {
							menuActionID[menuActionRow] = 412;
						}
						if (l == 2) {
							menuActionID[menuActionRow] = 225;
						}
						if (l == 3) {
							menuActionID[menuActionRow] = 965;
						}
						if (l == 4) {
							menuActionID[menuActionRow] = 478;
						}
						menuActionCmd1[menuActionRow] = i;
						menuActionCmd2[menuActionRow] = k;
						menuActionCmd3[menuActionRow] = j;
						menuActionRow++;
					}
				}
			}
			if (entity.actions != null) {
				for (int i1 = 4; i1 >= 0; i1--) {
					if ((entity.actions[i1] != null)
					&& entity.actions[i1].equalsIgnoreCase("attack")) {
						char c = '\0';
						if (entity.combatLevel > Client.myPlayer.combatLevel) {
							c = '\u07D0';
						}
						menuActionName[menuActionRow] = entity.actions[i1] + " @yel@" + s;
						if (i1 == 0) {
							menuActionID[menuActionRow] = 20 + c;
						}
						if (i1 == 1) {
							menuActionID[menuActionRow] = 412 + c;
						}
						if (i1 == 2) {
							menuActionID[menuActionRow] = 225 + c;
						}
						if (i1 == 3) {
							menuActionID[menuActionRow] = 965 + c;
						}
						if (i1 == 4) {
							menuActionID[menuActionRow] = 478 + c;
						}
						menuActionCmd1[menuActionRow] = i;
						menuActionCmd2[menuActionRow] = k;
						menuActionCmd3[menuActionRow] = j;
						menuActionRow++;
					}
				}
			}
			menuActionName[menuActionRow] = "Examine @yel@" + s + " @mag@(" + entity.type + ")";
			// menuActionName[menuActionRow] = "Examine @yel@" + s;
			menuActionID[menuActionRow] = 1025;
			menuActionCmd1[menuActionRow] = i;
			menuActionCmd2[menuActionRow] = k;
			menuActionCmd3[menuActionRow] = j;
			menuActionRow++;
		}
	}

	private void buildAtPlayerMenu(int i, int j, Player player, int k) {
		if (player == Client.myPlayer) {
			return;
		}
		if (menuActionRow >= 400) {
			return;
		}
		String s;
		if (player.skill == 0) {
			s = player.name
			+ Client.combatDifferenceColor(Client.myPlayer.combatLevel, player.combatLevel)
			+ " (level-" + player.combatLevel + ")";
		} else {
			s = player.name + " (skill-" + player.skill + ")";
		}
		if (itemSelected == 1) {
			menuActionName[menuActionRow] = "Use " + selectedItemName + " with @whi@" + s;
			menuActionID[menuActionRow] = 491;
			menuActionCmd1[menuActionRow] = j;
			menuActionCmd2[menuActionRow] = i;
			menuActionCmd3[menuActionRow] = k;
			menuActionRow++;
		} else if (spellSelected == 1) {
			if ((spellUsableOn & 8) == 8) {
				menuActionName[menuActionRow] = spellTooltip + " @whi@" + s;
				menuActionID[menuActionRow] = 365;
				menuActionCmd1[menuActionRow] = j;
				menuActionCmd2[menuActionRow] = i;
				menuActionCmd3[menuActionRow] = k;
				menuActionRow++;
			}
		} else {
			for (int l = 4; l >= 0; l--) {
				if (atPlayerActions[l] != null) {
					menuActionName[menuActionRow] = atPlayerActions[l] + " @whi@" + s;
					char c = '\0';
					if (atPlayerActions[l].equalsIgnoreCase("attack")) {
						if (player.combatLevel > Client.myPlayer.combatLevel) {
							c = '\u07D0';
						}
						if ((Client.myPlayer.team != 0) && (player.team != 0)) {
							if (Client.myPlayer.team == player.team) {
								c = '\u07D0';
							} else {
								c = '\0';
							}
						}
					} else if (atPlayerArray[l]) {
						c = '\u07D0';
					}
					if (l == 0) {
						menuActionID[menuActionRow] = 561 + c;
					}
					if (l == 1) {
						menuActionID[menuActionRow] = 779 + c;
					}
					if (l == 2) {
						menuActionID[menuActionRow] = 27 + c;
					}
					if (l == 3) {
						menuActionID[menuActionRow] = 577 + c;
					}
					if (l == 4) {
						menuActionID[menuActionRow] = 729 + c;
					}
					menuActionCmd1[menuActionRow] = j;
					menuActionCmd2[menuActionRow] = i;
					menuActionCmd3[menuActionRow] = k;
					menuActionRow++;
				}
			}
		}
		for (int i1 = 0; i1 < menuActionRow; i1++) {
			if (menuActionID[i1] == 516) {
				menuActionName[i1] = "Walk here @whi@" + s;
				return;
			}
		}
	}

	private void buildChatboxMenu(int j) {
		int l = 0;
		for (int i1 = 0; i1 < 500; i1++) {
			if (chatMessages[i1] == null) {
				continue;
			}
			int j1 = chatTypes[i1];
			int k1 = (70 - l * 14 + 42) + Client.scrollerPosition + 4 + 5;
			if (k1 < -23) {
				break;
			}
			String s = chatNames[i1];
			if (chatTypeView == 1) {
				buildPublicChat(j);
				break;
			}
			if (chatTypeView == 2) {
				buildFriendChat(j);
				break;
			}
			if ((chatTypeView == 3) || (chatTypeView == 4)) {
				buildDuelOrTrade(j);
				break;
			}
			if (chatTypeView == 5) {
				break;
			}
			if ((s != null) && s.startsWith("@cr1@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr2@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr3@")) {
				s = s.substring(5);
			}
			if (j1 == 0) {
				l++;
			}
			if (((j1 == 1) || (j1 == 2))
			&& ((j1 == 1) || (publicChatMode == 0) || ((publicChatMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1) && !s.equals(Client.myPlayer.name)) {
					if (myPrivilege >= 1) {
						menuActionName[menuActionRow] = "Report abuse @whi@" + s;
						menuActionID[menuActionRow] = 606;
						menuActionRow++;
					}
					menuActionName[menuActionRow] = "Add ignore @whi@" + s;
					menuActionID[menuActionRow] = 42;
					menuActionRow++;
					menuActionName[menuActionRow] = "Add friend @whi@" + s;
					menuActionID[menuActionRow] = 337;
					menuActionRow++;
				}
				l++;
			}
			if (((j1 == 3) || (j1 == 7))
			&& (splitPrivateChat == 0)
			&& ((j1 == 7) || (privateChatMode == 0) || ((privateChatMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1)) {
					if (myPrivilege >= 1) {
						menuActionName[menuActionRow] = "Report abuse @whi@" + s;
						menuActionID[menuActionRow] = 606;
						menuActionRow++;
					}
					menuActionName[menuActionRow] = "Add ignore @whi@" + s;
					menuActionID[menuActionRow] = 42;
					menuActionRow++;
					menuActionName[menuActionRow] = "Add friend @whi@" + s;
					menuActionID[menuActionRow] = 337;
					menuActionRow++;
				}
				l++;
			}
			if ((j1 == 4) && ((tradeMode == 0) || ((tradeMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1)) {
					menuActionName[menuActionRow] = "Accept trade @whi@" + s;
					menuActionID[menuActionRow] = 484;
					menuActionRow++;
				}
				l++;
			}
			if (((j1 == 5) || (j1 == 6)) && (splitPrivateChat == 0) && (privateChatMode < 2)) {
				l++;
			}
			if ((j1 == 8) && ((tradeMode == 0) || ((tradeMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1)) {
					menuActionName[menuActionRow] = "Accept challenge @whi@" + s;
					menuActionID[menuActionRow] = 6;
					menuActionRow++;
				}
				l++;
			}
		}
	}

	private void buildDuelOrTrade(int j) {
		int l = 0;
		for (int i1 = 0; i1 < 500; i1++) {
			if (chatMessages[i1] == null) {
				continue;
			}
			if ((chatTypeView != 3) && (chatTypeView != 4)) {
				continue;
			}
			int j1 = chatTypes[i1];
			String s = chatNames[i1];
			int k1 = (70 - l * 14 + 42) + Client.scrollerPosition + 4 + 5;
			if (k1 < -23) {
				break;
			}
			if ((s != null) && s.startsWith("@cr1@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr2@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr3@")) {
				s = s.substring(5);
			}
			if ((chatTypeView == 3) && (j1 == 4)
			&& ((tradeMode == 0) || ((tradeMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1)) {
					menuActionName[menuActionRow] = "Accept trade @whi@" + s;
					menuActionID[menuActionRow] = 484;
					menuActionRow++;
				}
				l++;
			}
			if ((chatTypeView == 4) && (j1 == 8)
			&& ((tradeMode == 0) || ((tradeMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1)) {
					menuActionName[menuActionRow] = "Accept challenge @whi@" + s;
					menuActionID[menuActionRow] = 6;
					menuActionRow++;
				}
				l++;
			}
			if (j1 == 12) {
				if ((j > k1 - 14) && (j <= k1)) {
					menuActionName[menuActionRow] = "Go-to @blu@" + s;
					menuActionID[menuActionRow] = 915;
					menuActionRow++;
				}
				l++;
			}
		}
	}

	private void buildFriendChat(int j) {
		int l = 0;
		for (int i1 = 0; i1 < 500; i1++) {
			if (chatMessages[i1] == null) {
				continue;
			}
			if (chatTypeView != 2) {
				continue;
			}
			int j1 = chatTypes[i1];
			String s = chatNames[i1];
			int k1 = (70 - l * 14 + 42) + Client.scrollerPosition + 4 + 5;
			if (k1 < -23) {
				break;
			}
			if ((s != null) && s.startsWith("@cr1@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr2@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr3@")) {
				s = s.substring(5);
			}
			if (((j1 == 5) || (j1 == 6))
			&& ((splitPrivateChat == 0) || (chatTypeView == 2))
			&& ((j1 == 6) || (privateChatMode == 0) || ((privateChatMode == 1) && isFriendOrSelf(s)))) {
				l++;
			}
			if (((j1 == 3) || (j1 == 7))
			&& ((splitPrivateChat == 0) || (chatTypeView == 2))
			&& ((j1 == 7) || (privateChatMode == 0) || ((privateChatMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1)) {
					if (myPrivilege >= 1) {
						menuActionName[menuActionRow] = "Report abuse @whi@" + s;
						menuActionID[menuActionRow] = 606;
						menuActionRow++;
					}
					menuActionName[menuActionRow] = "Add ignore @whi@" + s;
					menuActionID[menuActionRow] = 42;
					menuActionRow++;
					menuActionName[menuActionRow] = "Add friend @whi@" + s;
					menuActionID[menuActionRow] = 337;
					menuActionRow++;
				}
				l++;
			}
		}
	}

	private boolean buildFriendsListMenu(Interface iComponent) {
		int i = iComponent.contentType;
		if (((i >= 1) && (i <= 200)) || ((i >= 701) && (i <= 900))) {
			if (i >= 801) {
				i -= 701;
			} else if (i >= 701) {
				i -= 601;
			} else if (i >= 101) {
				i -= 101;
			} else {
				i--;
			}
			menuActionName[menuActionRow] = "Remove @whi@" + friendsList[i];
			menuActionID[menuActionRow] = 792;
			menuActionRow++;
			menuActionName[menuActionRow] = "Message @whi@" + friendsList[i];
			menuActionID[menuActionRow] = 639;
			menuActionRow++;
			return true;
		}
		if ((i >= 401) && (i <= 500)) {
			menuActionName[menuActionRow] = "Remove @whi@" + iComponent.message;
			menuActionID[menuActionRow] = 322;
			menuActionRow++;
			return true;
		} else {
			return false;
		}
	}

	private void buildInterfaceMenu(int i, Interface iComponent, int k, int l, int i1, int j1) {
		if ((iComponent.type != 0) || (iComponent.children == null) || iComponent.hoverable) {
			return;
		}
		if ((k < i) || (i1 < l) || (k > i + iComponent.width) || (i1 > l + iComponent.height)) {
			return;
		}
		int k1 = iComponent.children.length;
		for (int l1 = 0; l1 < k1; l1++) {
			int i2 = iComponent.childX[l1] + i;
			int j2 = (iComponent.childY[l1] + l) - j1;
			Interface children = Interface.interfaceCache[iComponent.children[l1]];
			i2 += children.anInt263;
			j2 += children.anInt265;
			if (((children.hover >= 0) || (children.anInt216 != 0)) && (k >= i2) && (i1 >= j2)
			&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
				if (children.hover >= 0) {
					anInt886 = children.hover;
				} else {
					anInt886 = children.id;
				}
			}
			if (children.type == 0) {
				buildInterfaceMenu(i2, children, k, j2, i1, children.scrollPosition);
				if (children.scrollMax > children.height) {
					method65(i2 + children.width, children.height, k, i1, children, j2, true,
					children.scrollMax);
				}
			} else {
				if ((children.atActionType == 1) && (k >= i2) && (i1 >= j2)
				&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
					boolean flag = false;
					if (children.contentType != 0) {
						flag = buildFriendsListMenu(children);
					}
					if (!flag) {
						menuActionName[menuActionRow] = children.tooltip + " @mag@(" + children.id
						+ ")";
						menuActionID[menuActionRow] = 315;
						menuActionCmd3[menuActionRow] = children.id;
						menuActionRow++;
					}
				}
				if ((children.atActionType == 2) && (spellSelected == 0) && (k >= i2) && (i1 >= j2)
				&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
					String s = children.selectedActionName;
					if (s.indexOf(" ") != -1) {
						s = s.substring(0, s.indexOf(" "));
					}
					menuActionName[menuActionRow] = s + " @gre@" + children.spellName;
					menuActionID[menuActionRow] = 626;
					menuActionCmd3[menuActionRow] = children.id;
					menuActionRow++;
				}
				if ((children.atActionType == 3) && (k >= i2) && (i1 >= j2)
				&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
					menuActionName[menuActionRow] = "Close";
					menuActionID[menuActionRow] = 200;
					menuActionCmd3[menuActionRow] = children.id;
					menuActionRow++;
				}
				if ((children.atActionType == 4) && (k >= i2) && (i1 >= j2)
				&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
					menuActionName[menuActionRow] = children.tooltip + " @mag@(" + children.id
					+ ")";
					menuActionID[menuActionRow] = 169;
					menuActionCmd3[menuActionRow] = children.id;
					menuActionRow++;
				}
				if ((children.atActionType == 5) && (k >= i2) && (i1 >= j2)
				&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
					menuActionName[menuActionRow] = children.tooltip + " @mag@(" + children.id
					+ ")";
					menuActionID[menuActionRow] = 646;
					menuActionCmd3[menuActionRow] = children.id;
					menuActionRow++;
				}
				if ((children.atActionType == 6) && !aBoolean1149 && (k >= i2) && (i1 >= j2)
				&& (k < i2 + children.width) && (i1 < j2 + children.height)) {
					menuActionName[menuActionRow] = children.tooltip + " @mag@(" + children.id
					+ ")";
					menuActionID[menuActionRow] = 679;
					menuActionCmd3[menuActionRow] = children.id;
					menuActionRow++;
				}
				if (children.type == 2) {
					int k2 = 0;
					for (int l2 = 0; l2 < children.height; l2++) {
						for (int i3 = 0; i3 < children.width; i3++) {
							int j3 = i2 + i3 * (32 + children.invSpritePadX);
							int k3 = j2 + l2 * (32 + children.invSpritePadY);
							if (k2 < 20) {
								j3 += children.spritesX[k2];
								k3 += children.spritesY[k2];
							}
							if ((k >= j3) && (i1 >= k3) && (k < j3 + 32) && (i1 < k3 + 32)) {
								mouseInvInterfaceIndex = k2;
								lastActiveInvInterface = children.id;
								if (children.inv[k2] > 0) {
									ItemDefinition itemDefinition = ItemDefinition
									.forID(children.inv[k2] - 1);
									if ((itemSelected == 1) && children.isInventoryInterface) {
										if ((children.id != anInt1284) || (k2 != anInt1283)) {
											menuActionName[menuActionRow] = "Use "
											+ selectedItemName + " with @lre@"
											+ itemDefinition.name;
											menuActionID[menuActionRow] = 870;
											menuActionCmd1[menuActionRow] = itemDefinition.itemID;
											menuActionCmd2[menuActionRow] = k2;
											menuActionCmd3[menuActionRow] = children.id;
											menuActionRow++;
										}
									} else if ((spellSelected == 1)
									&& children.isInventoryInterface) {
										if ((spellUsableOn & 16) == 16) {
											menuActionName[menuActionRow] = spellTooltip + " @lre@"
											+ itemDefinition.name;
											menuActionID[menuActionRow] = 543;
											menuActionCmd1[menuActionRow] = itemDefinition.itemID;
											menuActionCmd2[menuActionRow] = k2;
											menuActionCmd3[menuActionRow] = children.id;
											menuActionRow++;
										}
									} else {
										if (children.isInventoryInterface) {
											for (int l3 = 4; l3 >= 3; l3--) {
												if ((itemDefinition.actions != null)
												&& (itemDefinition.actions[l3] != null)) {
													menuActionName[menuActionRow] = itemDefinition.actions[l3]
													+ " @lre@" + itemDefinition.name;
													if (l3 == 3) {
														menuActionID[menuActionRow] = 493;
													}
													if (l3 == 4) {
														menuActionID[menuActionRow] = 847;
													}
													menuActionCmd1[menuActionRow] = itemDefinition.itemID;
													menuActionCmd2[menuActionRow] = k2;
													menuActionCmd3[menuActionRow] = children.id;
													menuActionRow++;
												} else if (l3 == 4) {
													menuActionName[menuActionRow] = "Drop @lre@"
													+ itemDefinition.name;
													menuActionID[menuActionRow] = 847;
													menuActionCmd1[menuActionRow] = itemDefinition.itemID;
													menuActionCmd2[menuActionRow] = k2;
													menuActionCmd3[menuActionRow] = children.id;
													menuActionRow++;
												}
											}
										}
										if (children.usableItemInterface) {
											menuActionName[menuActionRow] = "Use @lre@"
											+ itemDefinition.name;
											menuActionID[menuActionRow] = 447;
											menuActionCmd1[menuActionRow] = itemDefinition.itemID;
											menuActionCmd2[menuActionRow] = k2;
											menuActionCmd3[menuActionRow] = children.id;
											menuActionRow++;
										}
										if (children.isInventoryInterface
										&& (itemDefinition.actions != null)) {
											for (int i4 = 2; i4 >= 0; i4--) {
												if (itemDefinition.actions[i4] != null) {
													menuActionName[menuActionRow] = itemDefinition.actions[i4]
													+ " @lre@" + itemDefinition.name;
													if (i4 == 0) {
														menuActionID[menuActionRow] = 74;
													}
													if (i4 == 1) {
														menuActionID[menuActionRow] = 454;
													}
													if (i4 == 2) {
														menuActionID[menuActionRow] = 539;
													}
													menuActionCmd1[menuActionRow] = itemDefinition.itemID;
													menuActionCmd2[menuActionRow] = k2;
													menuActionCmd3[menuActionRow] = children.id;
													menuActionRow++;
												}
											}
										}
										if (children.actions != null) {
											for (int j4 = 4; j4 >= 0; j4--) {
												if (children.actions[j4] != null) {
													menuActionName[menuActionRow] = children.actions[j4]
													+ " @lre@" + itemDefinition.name;
													if (j4 == 0) {
														menuActionID[menuActionRow] = 632;
													}
													if (j4 == 1) {
														menuActionID[menuActionRow] = 78;
													}
													if (j4 == 2) {
														menuActionID[menuActionRow] = 867;
													}
													if (j4 == 3) {
														menuActionID[menuActionRow] = 431;
													}
													if (j4 == 4) {
														menuActionID[menuActionRow] = 53;
													}
													menuActionCmd1[menuActionRow] = itemDefinition.itemID;
													menuActionCmd2[menuActionRow] = k2;
													menuActionCmd3[menuActionRow] = children.id;
													menuActionRow++;
												}
											}
										}
										menuActionName[menuActionRow] = "Examine @lre@"
										+ itemDefinition.name + " @mag@(" + (children.inv[k2] - 1)
										+ ")";
										// menuActionName[menuActionRow] = "Examine @lre@" + itemDef.name;
										menuActionID[menuActionRow] = 1125;
										menuActionCmd1[menuActionRow] = itemDefinition.itemID;
										menuActionCmd2[menuActionRow] = k2;
										menuActionCmd3[menuActionRow] = children.id;
										menuActionRow++;
									}
								}
							}
							k2++;
						}
					}
				}
			}
		}
	}

	private void buildPublicChat(int j) {
		int l = 0;
		for (int i1 = 0; i1 < 500; i1++) {
			if (chatMessages[i1] == null) {
				continue;
			}
			if (chatTypeView != 1) {
				continue;
			}
			int j1 = chatTypes[i1];
			String s = chatNames[i1];
			int k1 = (70 - l * 14 + 42) + Client.scrollerPosition + 4 + 5;
			if (k1 < -23) {
				break;
			}
			if ((s != null) && s.startsWith("@cr1@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr2@")) {
				s = s.substring(5);
			}
			if ((s != null) && s.startsWith("@cr3@")) {
				s = s.substring(5);
			}
			if (((j1 == 1) || (j1 == 2))
			&& ((j1 == 1) || (publicChatMode == 0) || ((publicChatMode == 1) && isFriendOrSelf(s)))) {
				if ((j > k1 - 14) && (j <= k1) && !s.equals(Client.myPlayer.name)) {
					if (myPrivilege >= 1) {
						menuActionName[menuActionRow] = "Report abuse @whi@" + s;
						menuActionID[menuActionRow] = 606;
						menuActionRow++;
					}
					menuActionName[menuActionRow] = "Add ignore @whi@" + s;
					menuActionID[menuActionRow] = 42;
					menuActionRow++;
					menuActionName[menuActionRow] = "Add friend @whi@" + s;
					menuActionID[menuActionRow] = 337;
					menuActionRow++;
				}
				l++;
			}
		}
	}

	private void buildSplitPrivateChatMenu() {
		if (splitPrivateChat == 0) {
			return;
		}
		int i = 0;
		if (anInt1104 != 0) {
			i = 1;
		}
		for (int j = 0; j < 100; j++) {
			if (chatMessages[j] != null) {
				int k = chatTypes[j];
				String s = chatNames[j];
				if ((s != null) && s.startsWith("@cr1@")) {
					s = s.substring(5);
				}
				if ((s != null) && s.startsWith("@cr2@")) {
					s = s.substring(5);
				}
				if (((k == 3) || (k == 7))
				&& ((k == 7) || (privateChatMode == 0) || ((privateChatMode == 1) && isFriendOrSelf(s)))) {
					int l = 329 - i * 13;
					if ((super.mouseX > 4) && (super.mouseY - 4 > l - 10)
					&& (super.mouseY - 4 <= l + 3)) {
						int i1 = plainText.getTextWidth("From:  " + s + chatMessages[j]) + 25;
						if (i1 > 450) {
							i1 = 450;
						}
						if (super.mouseX < 4 + i1) {
							if (myPrivilege >= 1) {
								menuActionName[menuActionRow] = "Report abuse @whi@" + s;
								menuActionID[menuActionRow] = 2606;
								menuActionRow++;
							}
							menuActionName[menuActionRow] = "Add ignore @whi@" + s;
							menuActionID[menuActionRow] = 2042;
							menuActionRow++;
							menuActionName[menuActionRow] = "Add friend @whi@" + s;
							menuActionID[menuActionRow] = 2337;
							menuActionRow++;
						}
					}
					if (++i >= 5) {
						return;
					}
				}
				if (((k == 5) || (k == 6)) && (privateChatMode < 2) && (++i >= 5)) {
					return;
				}
			}
		}
	}

	private void getCameraPos() {
		int i = anInt1098 * 128 + 64;
		int j = anInt1099 * 128 + 64;
		int k = getEntityHeightOffset(plane, j, i) - anInt1100;
		if (xCameraPos < i) {
			xCameraPos += anInt1101 + ((i - xCameraPos) * anInt1102) / 1000;
			if (xCameraPos > i) {
				xCameraPos = i;
			}
		}
		if (xCameraPos > i) {
			xCameraPos -= anInt1101 + ((xCameraPos - i) * anInt1102) / 1000;
			if (xCameraPos < i) {
				xCameraPos = i;
			}
		}
		if (zCameraPos < k) {
			zCameraPos += anInt1101 + ((k - zCameraPos) * anInt1102) / 1000;
			if (zCameraPos > k) {
				zCameraPos = k;
			}
		}
		if (zCameraPos > k) {
			zCameraPos -= anInt1101 + ((zCameraPos - k) * anInt1102) / 1000;
			if (zCameraPos < k) {
				zCameraPos = k;
			}
		}
		if (yCameraPos < j) {
			yCameraPos += anInt1101 + ((j - yCameraPos) * anInt1102) / 1000;
			if (yCameraPos > j) {
				yCameraPos = j;
			}
		}
		if (yCameraPos > j) {
			yCameraPos -= anInt1101 + ((yCameraPos - j) * anInt1102) / 1000;
			if (yCameraPos < j) {
				yCameraPos = j;
			}
		}
		i = anInt995 * 128 + 64;
		j = anInt996 * 128 + 64;
		k = getEntityHeightOffset(plane, j, i) - anInt997;
		int l = i - xCameraPos;
		int i1 = k - zCameraPos;
		int j1 = j - yCameraPos;
		int k1 = (int) Math.sqrt(l * l + j1 * j1);
		int l1 = (int) (Math.atan2(i1, k1) * 325.94900000000001D) & 0x7ff;
		int i2 = (int) (Math.atan2(l, j1) * -325.94900000000001D) & 0x7ff;
		if (l1 < 128) {
			l1 = 128;
		}
		if (l1 > 383) {
			l1 = 383;
		}
		if (cameraPitch < l1) {
			cameraPitch += anInt998 + ((l1 - cameraPitch) * anInt999) / 1000;
			if (cameraPitch > l1) {
				cameraPitch = l1;
			}
		}
		if (cameraPitch > l1) {
			cameraPitch -= anInt998 + ((cameraPitch - l1) * anInt999) / 1000;
			if (cameraPitch < l1) {
				cameraPitch = l1;
			}
		}
		int j2 = i2 - cameraYaw;
		if (j2 > 1024) {
			j2 -= 2048;
		}
		if (j2 < -1024) {
			j2 += 2048;
		}
		if (j2 > 0) {
			cameraYaw += anInt998 + (j2 * anInt999) / 1000;
			cameraYaw &= 0x7ff;
		}
		if (j2 < 0) {
			cameraYaw -= anInt998 + (-j2 * anInt999) / 1000;
			cameraYaw &= 0x7ff;
		}
		int k2 = i2 - cameraYaw;
		if (k2 > 1024) {
			k2 -= 2048;
		}
		if (k2 < -1024) {
			k2 += 2048;
		}
		if (((k2 < 0) && (j2 > 0)) || ((k2 > 0) && (j2 < 0))) {
			cameraYaw = i2;
		}
	}

	private void getEntityScreenPos(int x, int height, int y) {
		if ((x < 128) || (y < 128) || (x > 13056) || (y > 13056)) {
			spriteDrawX = -1;
			spriteDrawY = -1;
			return;
		}
		int z = getEntityHeightOffset(plane, y, x) - height;
		x -= xCameraPos;
		z -= zCameraPos;
		y -= yCameraPos;
		int sineY = Model.sineTable[cameraPitch];
		int cosineY = Model.cosineTable[cameraPitch];
		int sineX = Model.sineTable[cameraYaw];
		int cosineX = Model.cosineTable[cameraYaw];
		int j2 = y * sineX + x * cosineX >> 16;
		y = y * cosineX - x * sineX >> 16;
		x = j2;
		j2 = z * cosineY - y * sineY >> 16;
		y = z * sineY + y * cosineY >> 16;
		z = j2;
		if (y >= 50) {
			spriteDrawX = Renderer3D.middleX + (x << 9) / y;
			spriteDrawY = Renderer3D.middleY + (z << 9) / y;
		} else {
			spriteDrawX = -1;
			spriteDrawY = -1;
		}
	}

	private void calcFlamesPosition() {
		char c = '\u0100';
		for (int j = 10; j < 117; j++) {
			int k = (int) (Math.random() * 100D);
			if (k < 50) {
				anIntArray828[j + (c - 2 << 7)] = 255;
			}
		}
		for (int l = 0; l < 100; l++) {
			int i1 = (int) (Math.random() * 124D) + 2;
			int k1 = (int) (Math.random() * 128D) + 128;
			int k2 = i1 + (k1 << 7);
			anIntArray828[k2] = 192;
		}
		for (int j1 = 1; j1 < c - 1; j1++) {
			for (int l1 = 1; l1 < 127; l1++) {
				int l2 = l1 + (j1 << 7);
				anIntArray829[l2] = (anIntArray828[l2 - 1] + anIntArray828[l2 + 1]
				+ anIntArray828[l2 - 128] + anIntArray828[l2 + 128]) / 4;
			}
		}
		anInt1275 += 128;
		if (anInt1275 > anIntArray1190.length) {
			anInt1275 -= anIntArray1190.length;
			int i2 = (int) (Math.random() * 12D);
			randomizeImage(runes[i2]);
		}
		for (int j2 = 1; j2 < c - 1; j2++) {
			for (int i3 = 1; i3 < 127; i3++) {
				int k3 = i3 + (j2 << 7);
				int i4 = anIntArray829[k3 + 128]
				- anIntArray1190[k3 + anInt1275 & anIntArray1190.length - 1] / 5;
				if (i4 < 0) {
					i4 = 0;
				}
				anIntArray828[k3] = i4;
			}
		}
		System.arraycopy(anIntArray969, 1, anIntArray969, 0, c - 1);
		anIntArray969[c - 1] = (int) (Math.sin(Client.loopCycle / 14D) * 16D
		+ Math.sin(Client.loopCycle / 15D) * 14D + Math.sin(Client.loopCycle / 16D) * 12D);
		if (anInt1040 > 0) {
			anInt1040 -= 4;
		}
		if (anInt1041 > 0) {
			anInt1041 -= 4;
		}
		if ((anInt1040 == 0) && (anInt1041 == 0)) {
			int l3 = (int) (Math.random() * 2000D);
			if (l3 == 0) {
				anInt1040 = 1024;
			}
			if (l3 == 1) {
				anInt1041 = 1024;
			}
		}
	}

	private int calcGlobeTextColor(int percent) {
		if (percent > 75) {
			return 0x00ff00;
		} else if (percent > 50) {
			return 0xffff00;
		} else if (percent > 25) {
			return 0xff981f;
		} else {
			return 0xff0000;
		}
	}

	@Override
	public void cleanUpForQuit() {
		Signlink.reporterror = false;
		try {
			if (socketStream != null) {
				socketStream.close();
			}
		} catch (Exception _ex) {
		}
		socketStream = null;
		stopMidi();
		if (mouseDetection != null) {
			mouseDetection.running = false;
		}
		mouseDetection = null;
		onDemandFetcher.disable();
		onDemandFetcher = null;
		chatBuffers = null;
		outputStream = null;
		settingsBuffers = null;
		inputStream = null;
		anIntArray1234 = null;
		aByteArrayArray1183 = null;
		aByteArrayArray1247 = null;
		anIntArray1235 = null;
		anIntArray1236 = null;
		averageTileHeight = null;
		byteGroundArray = null;
		sceneGraph = null;
		collisionMap = null;
		anIntArrayArray901 = null;
		anIntArrayArray825 = null;
		bigX = null;
		bigY = null;
		destTexture = null;
		inventoryCanvas = null;
		leftFrame = null;
		topFrame = null;
		minimapCanvas = null;
		gameScreenCanvas = null;
		chatboxCanvas = null;
		chatBox = null;
		filterButtons = null;
		inventory = null;
		roundMapBack = null;
		worldMapGlobe = null;
		mapBackground = null;
		sideIcons = null;
		logoutDoor = null;
		redStones = null;
		compass = null;
		hitMarks = null;
		newHitMarks = null;
		headIcons_prayer = null;
		headIcons_pk = null;
		headIcons_hint = null;
		crosses = null;
		mapDotItem = null;
		mapDotNPC = null;
		mapDotPlayer = null;
		mapDotFriend = null;
		mapDotTeam = null;
		mapScenes = null;
		mapFunctions = null;
		anIntArrayArray929 = null;
		playerArray = null;
		playerIndices = null;
		anIntArray894 = null;
		playerAppearanceBuffers = null;
		anIntArray840 = null;
		npcArray = null;
		npcIndices = null;
		groundArray = null;
		aClass19_1179 = null;
		projectileList = null;
		stillGraphicList = null;
		menuActionCmd2 = null;
		menuActionCmd3 = null;
		menuActionID = null;
		menuActionCmd1 = null;
		menuActionName = null;
		variousSettings = null;
		anIntArray1072 = null;
		anIntArray1073 = null;
		aClass30_Sub2_Sub1_Sub1Array1140 = null;
		miniMap = null;
		friendsList = null;
		friendsListAsLongs = null;
		friendsNodeIDs = null;
		leftFlameCanvas = null;
		rightFlameCanvas = null;
		topLeftCanvas = null;
		bottomLeftCanvas = null;
		leftCanvas = null;
		titleBoxLeftCanvas = null;
		bottomRightCanvas = null;
		smallLeftCanvas = null;
		smallRightCanvas = null;
		nullLoader();
		ObjectDefinition.nullLoader();
		EntityDefinition.nullLoader();
		ItemDefinition.nullLoader();
		Floor.cache = null;
		IdentityKit.cache = null;
		Interface.interfaceCache = null;
		DummyClass.cache = null;
		Animation.animations = null;
		SpotAnimation.cache = null;
		SpotAnimation.gfxCache = null;
		Varp.cache = null;
		super.fullGameScreen = null;
		Player.modelCache = null;
		Renderer3D.nullLoader();
		SceneGraph.nullLoader();
		Model.nullLoader();
		FrameReader.nullLoader();
		System.gc();
	}

	public void clearTopInterfaces() {
		outputStream.putOperation(130);
		if (invOverlayInterfaceID != -1) {
			invOverlayInterfaceID = -1;
			drawInventoryRequest = true;
			aBoolean1149 = false;
			inventoryAltered = true;
		}
		if (backDialogID != -1) {
			backDialogID = -1;
			Client.inputTaken = true;
			aBoolean1149 = false;
		}
		openInterfaceID = -1;
		fullscreenInterfaceID = -1;
	}

	private void delFriend(long l) {
		try {
			if (l == 0L) {
				return;
			}
			for (int i = 0; i < friendsCount; i++) {
				if (friendsListAsLongs[i] != l) {
					continue;
				}
				friendsCount--;
				drawInventoryRequest = true;
				for (int j = i; j < friendsCount; j++) {
					friendsList[j] = friendsList[j + 1];
					friendsNodeIDs[j] = friendsNodeIDs[j + 1];
					friendsListAsLongs[j] = friendsListAsLongs[j + 1];
				}
				outputStream.putOperation(215);
				outputStream.putLong(l);
				break;
			}
		} catch (RuntimeException runtimeexception) {
			Signlink.reporterror("18622, " + false + ", " + l + ", " + runtimeexception.toString());
			throw new RuntimeException();
		}
	}

	private void removeIgnore(long l) {
		try {
			if (l == 0L) {
				return;
			}
			for (int j = 0; j < ignoreCount; j++) {
				if (ignoreListAsLongs[j] == l) {
					ignoreCount--;
					drawInventoryRequest = true;
					System.arraycopy(ignoreListAsLongs, j + 1, ignoreListAsLongs, j, ignoreCount
					- j);
					outputStream.putOperation(74);
					outputStream.putLong(l);
					return;
				}
			}
			return;
		} catch (RuntimeException runtimeexception) {
			Signlink.reporterror("47229, " + 3 + ", " + l + ", " + runtimeexception.toString());
		}
		throw new RuntimeException();
	}

	private void determineMenuSize() {
		int boxLength = boldText.getTextWidth("Choose option");
		for (int row = 0; row < menuActionRow; row++) {
			int actionLength = boldText.getTextWidth(menuActionName[row]);
			if (actionLength > boxLength) {
				boxLength = actionLength;
			}
		}
		boxLength += 8;
		int offset = 15 * menuActionRow + 21;
		if ((super.saveClickX > 0) && (super.saveClickY > 0) && (super.saveClickX < 765)
		&& (super.saveClickY < 503)) {
			int x = super.saveClickX - boxLength / 2;
			if (x + boxLength > 761) {
				x = 761 - boxLength;
			}
			if (x < 0) {
				x = 0;
			}
			int y = super.saveClickY - 0;
			if (y + offset > 497) {
				y = 497 - offset;
			}
			if (y < 0) {
				y = 0;
			}
			menuOpen = true;
			menuOffsetX = x;
			menuOffsetY = y;
			menuWidth = boxLength;
			menuHeight = 15 * menuActionRow + 22;
		}
	}

	private void doAction(int i) {
		if (i < 0) {
			return;
		}
		if (inputDialogState != 0) {
			inputDialogState = 0;
			Client.inputTaken = true;
		}
		int optionOne = menuActionCmd1[i];
		int optionTwo = menuActionCmd2[i];
		int optionThree = menuActionCmd3[i];
		int id = menuActionID[i];
		if (id >= 2000) {
			id -= 2000;
		}
		if (id == 20) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(155);
				outputStream.putLEShort(optionOne);
			}
		}
		if ((id == 6) || (id == 484)) { // Player following?
			String s1 = menuActionName[i];
			int l1 = s1.indexOf("@whi@");
			if (l1 != -1) {
				s1 = s1.substring(l1 + 5).trim();
				String formattedName = TextUtil.fixName(TextUtil.nameForLong(TextUtil
				.longForName(s1)));
				boolean flag9 = false;
				for (int j3 = 0; j3 < playerCount; j3++) {
					Player player = playerArray[playerIndices[j3]];
					if ((player == null) || (player.name == null)
					|| !player.name.equalsIgnoreCase(formattedName)) {
						continue;
					}
					doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
					Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
					if (id == 6) {
						Client.anInt1188 += optionOne;
						if (Client.anInt1188 >= 90) {
							outputStream.putOperation(136);
							Client.anInt1188 = 0;
						}
						outputStream.putOperation(128);
						outputStream.putShort(playerIndices[j3]);
					}
					if (id == 484) {
						outputStream.putOperation(139);
						outputStream.putLEShort(playerIndices[j3]);
					}
					flag9 = true;
					break;
				}
				if (!flag9) {
					pushMessage("Unable to find " + formattedName, 0, "");
				}
			}
		}
		if (id == 27) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				Client.anInt986 += optionOne;
				if (Client.anInt986 >= 54) {
					outputStream.putOperation(189);
					outputStream.putByte(234);
					Client.anInt986 = 0;
				}
				outputStream.putOperation(73);
				outputStream.putLEShort(optionOne);
			}
		}
		if ((id == 42) || (id == 322) || (id == 337) || (id == 792)) {
			String s = menuActionName[i];
			int playerInput = s.indexOf("@whi@");
			if (playerInput != -1) {
				long formattedName = TextUtil.longForName(s.substring(playerInput + 5).trim());
				if (id == 42) {
					addIgnore(formattedName);
				}
				if (id == 322) {
					removeIgnore(formattedName);
				}
				if (id == 337) {
					addFriend(formattedName);
				}
				if (id == 792) {
					delFriend(formattedName);
				}
			}
		}
		if (id == 53) {
			outputStream.putOperation(135);
			outputStream.putLEShort(optionTwo);
			outputStream.putShortA(optionThree);
			outputStream.putLEShort(optionOne);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if ((id == 62) && method66(optionOne, optionThree, optionTwo)) {
			outputStream.putOperation(192);
			outputStream.putShort(anInt1284);
			outputStream.putLEShort(optionOne >> 14 & 0x7fff);
			outputStream.putLEShortA(optionThree + baseY);
			outputStream.putLEShort(anInt1283);
			outputStream.putLEShortA(optionTwo + baseX);
			outputStream.putShort(anInt1285);
		}
		if (id == 74) {
			outputStream.putOperation(122);
			outputStream.putLEShortA(optionThree);
			outputStream.putShortA(optionTwo);
			outputStream.putLEShort(optionOne);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 78) {
			outputStream.putOperation(117);
			outputStream.putLEShortA(optionThree);
			outputStream.putLEShortA(optionOne);
			outputStream.putLEShort(optionTwo);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 94) {
			boolean flag5 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag5) {
				flag5 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(181);
			outputStream.putLEShort(optionThree + baseY);
			outputStream.putShort(optionOne);
			outputStream.putLEShort(optionTwo + baseX);
			outputStream.putShortA(anInt1137);
		}
		if (id == 113) {
			method66(optionOne, optionThree, optionTwo);
			outputStream.putOperation(70);
			outputStream.putLEShort(optionTwo + baseX);
			outputStream.putShort(optionThree + baseY);
			outputStream.putLEShortA(optionOne >> 14 & 0x7fff);
		}
		if (id == 169) {
			outputStream.putOperation(185);
			outputStream.putShort(optionThree);
			Interface iComponent = Interface.interfaceCache[optionThree];
			if ((iComponent.valueIndexArray != null) && (iComponent.valueIndexArray[0][0] == 5)) {
				int l2 = iComponent.valueIndexArray[0][1];
				variousSettings[l2] = 1 - variousSettings[l2];
				processClientOptions(l2);
				drawInventoryRequest = true;
			}
		}
		if (id == 200) {
			clearTopInterfaces();
		}
		if (id == 213) {
			boolean flag3 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag3) {
				flag3 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(79);
			outputStream.putLEShort(optionThree + baseY);
			outputStream.putShort(optionOne);
			outputStream.putShortA(optionTwo + baseX);
		}
		if (id == 225) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				Client.anInt1226 += optionOne;
				if (Client.anInt1226 >= 85) {
					outputStream.putOperation(230);
					outputStream.putByte(239);
					Client.anInt1226 = 0;
				}
				outputStream.putOperation(17);
				outputStream.putLEShortA(optionOne);
			}
		}
		if (id == 234) {
			boolean flag1 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag1) {
				flag1 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(236);
			outputStream.putLEShort(optionThree + baseY);
			outputStream.putShort(optionOne);
			outputStream.putLEShort(optionTwo + baseX);
		}
		if (id == 244) {
			boolean flag7 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag7) {
				flag7 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(253);
			outputStream.putLEShort(optionTwo + baseX);
			outputStream.putLEShortA(optionThree + baseY);
			outputStream.putShortA(optionOne);
		}
		if (id == 315) {
			Interface iComponent = Interface.interfaceCache[optionThree];
			boolean flag8 = true;
			if (iComponent.contentType > 0) {
				flag8 = promptUserForInput(iComponent);
			}
			if (flag8) {
				outputStream.putOperation(185);
				outputStream.putShort(optionThree);
			}
		}
		if (id == 365) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(249);
				outputStream.putShortA(optionOne);
				outputStream.putLEShort(anInt1137);
			}
		}
		if (id == 412) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(72);
				outputStream.putShortA(optionOne);
			}
		}
		if (id == 413) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(131);
				outputStream.putLEShortA(optionOne);
				outputStream.putShortA(anInt1137);
			}
		}
		if (id == 431) {
			outputStream.putOperation(129);
			outputStream.putShortA(optionTwo);
			outputStream.putShort(optionThree);
			outputStream.putShortA(optionOne);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 447) {
			itemSelected = 1;
			anInt1283 = optionTwo;
			anInt1284 = optionThree;
			anInt1285 = optionOne;
			selectedItemName = ItemDefinition.forID(optionOne).name;
			spellSelected = 0;
			drawInventoryRequest = true;
			return;
		}
		if (id == 454) {
			outputStream.putOperation(41);
			outputStream.putShort(optionOne);
			outputStream.putShortA(optionTwo);
			outputStream.putShortA(optionThree);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 478) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				if ((optionOne & 3) == 0) {
					Client.anInt1155++;
				}
				if (Client.anInt1155 >= 53) {
					outputStream.putOperation(85);
					outputStream.putByte(66);
					Client.anInt1155 = 0;
				}
				outputStream.putOperation(18);
				outputStream.putLEShort(optionOne);
			}
		}
		if (id == 491) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(14);
				outputStream.putShortA(anInt1284);
				outputStream.putShort(optionOne);
				outputStream.putShort(anInt1285);
				outputStream.putLEShort(anInt1283);
			}
		}
		if (id == 493) {
			outputStream.putOperation(75);
			outputStream.putLEShortA(optionThree);
			outputStream.putLEShort(optionTwo);
			outputStream.putShortA(optionOne);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 502) {
			method66(optionOne, optionThree, optionTwo);
			outputStream.putOperation(132);
			outputStream.putLEShortA(optionTwo + baseX);
			outputStream.putShort(optionOne >> 14 & 0x7fff);
			outputStream.putShortA(optionThree + baseY);
		}
		if (id == 511) {
			boolean flag2 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag2) {
				flag2 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(25);
			outputStream.putLEShort(anInt1284);
			outputStream.putShortA(anInt1285);
			outputStream.putShort(optionOne);
			outputStream.putShortA(optionThree + baseY);
			outputStream.putLEShortA(anInt1283);
			outputStream.putShort(optionTwo + baseX);
		}
		if (id == 516) {
			if (!menuOpen) {
				sceneGraph.method312(super.saveClickY - 4, super.saveClickX - 4);
			} else {
				sceneGraph.method312(optionThree - 4, optionTwo - 4);
			}
		}
		if (id == 539) {
			outputStream.putOperation(16);
			outputStream.putShortA(optionOne);
			outputStream.putLEShortA(optionTwo);
			outputStream.putLEShortA(optionThree);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 543) {
			outputStream.putOperation(237);
			outputStream.putShort(optionTwo);
			outputStream.putShortA(optionOne);
			outputStream.putShort(optionThree);
			outputStream.putShortA(anInt1137);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 561) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				Client.anInt1188 += optionOne;
				if (Client.anInt1188 >= 90) {
					outputStream.putOperation(136);
					Client.anInt1188 = 0;
				}
				outputStream.putOperation(128);
				outputStream.putShort(optionOne);
			}
		}
		if (id == 567) {
			boolean flag6 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag6) {
				flag6 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(23);
			outputStream.putLEShort(optionThree + baseY);
			outputStream.putLEShort(optionOne);
			outputStream.putLEShort(optionTwo + baseX);
		}
		if (id == 577) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(139);
				outputStream.putLEShort(optionOne);
			}
		}
		if (id == 582) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(57);
				outputStream.putShortA(anInt1285);
				outputStream.putShortA(optionOne);
				outputStream.putLEShort(anInt1283);
				outputStream.putShortA(anInt1284);
			}
		}
		if (id == 606) {
			String s2 = menuActionName[i];
			int j2 = s2.indexOf("@whi@");
			if (j2 != -1) {
				if (openInterfaceID == -1) {
					clearTopInterfaces();
					reportAbuseInput = s2.substring(j2 + 5).trim();
					canMute = false;
					for (Interface element : Interface.interfaceCache) {
						if ((element == null) || (element.contentType != 600)) {
							continue;
						}
						reportAbuseInterfaceID = openInterfaceID = element.parentID;
						break;
					}
				} else {
					pushMessage(
					"Please close the interface you have open before using 'report abuse'", 0, "");
				}
			}
		}
		if (id == 626) {
			Interface iComponent = Interface.interfaceCache[optionThree];
			spellSelected = 1;
			anInt1137 = optionThree;
			spellUsableOn = iComponent.spellUsableOn;
			itemSelected = 0;
			drawInventoryRequest = true;
			String s4 = iComponent.selectedActionName;
			if (s4.indexOf(" ") != -1) {
				s4 = s4.substring(0, s4.indexOf(" "));
			}
			String s8 = iComponent.selectedActionName;
			if (s8.indexOf(" ") != -1) {
				s8 = s8.substring(s8.indexOf(" ") + 1);
			}
			spellTooltip = s4 + " " + iComponent.spellName + " " + s8;
			if (spellUsableOn == 16) {
				drawInventoryRequest = true;
				tabID = 3;
				inventoryAltered = true;
			}
			return;
		}
		if (id == 632) {
			outputStream.putOperation(145);
			outputStream.putShortA(optionThree);
			outputStream.putShortA(optionTwo);
			outputStream.putShortA(optionOne);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 639) {
			String s3 = menuActionName[i];
			int k2 = s3.indexOf("@whi@");
			if (k2 != -1) {
				long formattedName = TextUtil.longForName(s3.substring(k2 + 5).trim());
				int k3 = -1;
				for (int i4 = 0; i4 < friendsCount; i4++) {
					if (friendsListAsLongs[i4] != formattedName) {
						continue;
					}
					k3 = i4;
					break;
				}
				if ((k3 != -1) && (friendsNodeIDs[k3] > 0)) {
					Client.inputTaken = true;
					inputDialogState = 0;
					messagePromptRaised = true;
					promptInput = "";
					friendsListAction = 3;
					aLong953 = friendsListAsLongs[k3];
					messagePromptTitle = "Enter message to send to " + friendsList[k3];
				}
			}
		}
		if (id == 646) {
			outputStream.putOperation(185);
			outputStream.putShort(optionThree);
			Interface iComponent = Interface.interfaceCache[optionThree];
			if ((iComponent.valueIndexArray != null) && (iComponent.valueIndexArray[0][0] == 5)) {
				int i2 = iComponent.valueIndexArray[0][1];
				if (variousSettings[i2] != iComponent.anIntArray212[0]) {
					variousSettings[i2] = iComponent.anIntArray212[0];
					processClientOptions(i2);
					drawInventoryRequest = true;
				}
			}
		}
		if (id == 652) {
			boolean flag4 = doWalkTo(2, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, optionThree,
			Client.myPlayer.walkQueueX[0], false, optionTwo);
			if (!flag4) {
				flag4 = doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, optionThree,
				Client.myPlayer.walkQueueX[0], false, optionTwo);
			}
			crossX = super.saveClickX;
			crossY = super.saveClickY;
			crossType = 2;
			crossIndex = 0;
			outputStream.putOperation(156);
			outputStream.putShortA(optionTwo + baseX);
			outputStream.putLEShort(optionThree + baseY);
			outputStream.putLEShortA(optionOne);
		}
		if ((id == 679) && !aBoolean1149) {
			outputStream.putOperation(40);
			outputStream.putShort(optionThree);
			aBoolean1149 = true;
		}
		if (id == 729) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(39);
				outputStream.putLEShort(optionOne);
			}
		}
		if (id == 779) {
			Player player = playerArray[optionOne];
			if (player != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, player.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, player.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				outputStream.putOperation(153);
				outputStream.putLEShort(optionOne);
			}
		}
		if (id == 847) {
			outputStream.putOperation(87);
			outputStream.putShortA(optionOne);
			outputStream.putShort(optionThree);
			outputStream.putShortA(optionTwo);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 867) {
			if ((optionOne & 3) == 0) {
				Client.anInt1175++;
			}
			if (Client.anInt1175 >= 59) {
				outputStream.putOperation(200);
				outputStream.putShort(25501);
				Client.anInt1175 = 0;
			}
			outputStream.putOperation(43);
			outputStream.putLEShort(optionThree);
			outputStream.putShortA(optionOne);
			outputStream.putShortA(optionTwo);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 870) {
			outputStream.putOperation(53);
			outputStream.putShort(optionTwo);
			outputStream.putShortA(anInt1283);
			outputStream.putLEShortA(optionOne);
			outputStream.putShort(anInt1284);
			outputStream.putLEShort(anInt1285);
			outputStream.putShort(optionThree);
			atInventoryLoopCycle = 0;
			atInventoryInterface = optionThree;
			atInventoryIndex = optionTwo;
			atInventoryInterfaceType = 2;
			if (Interface.interfaceCache[optionThree].parentID == openInterfaceID) {
				atInventoryInterfaceType = 1;
			}
			if (Interface.interfaceCache[optionThree].parentID == backDialogID) {
				atInventoryInterfaceType = 3;
			}
		}
		if (id == 872) {
			method66(optionOne, optionThree, optionTwo);
			outputStream.putOperation(234);
			outputStream.putLEShortA(optionTwo + baseX);
			outputStream.putShortA(optionOne >> 14 & 0x7fff);
			outputStream.putLEShortA(optionThree + baseY);
		}
		if (id == 900) {
			method66(optionOne, optionThree, optionTwo);
			outputStream.putOperation(252);
			outputStream.putLEShortA(optionOne >> 14 & 0x7fff);
			outputStream.putLEShort(optionThree + baseY);
			outputStream.putShortA(optionTwo + baseX);
		}
		if ((id == 956) && method66(optionOne, optionThree, optionTwo)) {
			outputStream.putOperation(35);
			outputStream.putLEShort(optionTwo + baseX);
			outputStream.putShortA(anInt1137);
			outputStream.putShortA(optionThree + baseY);
			outputStream.putLEShort(optionOne >> 14 & 0x7fff);
		}
		if (id == 965) {
			Npc npc = npcArray[optionOne];
			if (npc != null) {
				doWalkTo(2, 0, 1, 0, Client.myPlayer.walkQueueY[0], 1, 0, npc.walkQueueY[0],
				Client.myPlayer.walkQueueX[0], false, npc.walkQueueX[0]);
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 2;
				crossIndex = 0;
				Client.anInt1134++;
				if (Client.anInt1134 >= 96) {
					outputStream.putOperation(152);
					outputStream.putByte(88);
					Client.anInt1134 = 0;
				}
				outputStream.putOperation(21);
				outputStream.putShort(optionOne);
			}
		}
		if (id == 1025) {
			Npc npc = npcArray[optionOne];
			String indefinite = "a";
			if (npc != null) {
				EntityDefinition entityDefinition = npc.desc;
				if (entityDefinition.childrenIDs != null) {
					entityDefinition = entityDefinition.method161();
				}
				if (entityDefinition != null) {
					String examineInfo;
					if (entityDefinition.description != null) {
						examineInfo = new String(entityDefinition.description);
					} else {
						if ((entityDefinition.name.charAt(0) == 'A')
						|| (entityDefinition.name.charAt(0) == 'E')
						|| (entityDefinition.name.charAt(0) == 'I')
						|| (entityDefinition.name.charAt(0) == 'O')
						|| (entityDefinition.name.charAt(0) == 'U')) {
							indefinite = "an";
						}
						examineInfo = "It's " + indefinite + " " + entityDefinition.name + ".";
					}
					pushMessage(examineInfo, 0, "");
				}
			}
		}
		if (id == 1062) {
			Client.anInt924 += baseX;
			if (Client.anInt924 >= 113) {
				outputStream.putOperation(183);
				outputStream.put24BitInt(15086193);
				Client.anInt924 = 0;
			}
			method66(optionOne, optionThree, optionTwo);
			outputStream.putOperation(228);
			outputStream.putShortA(optionOne >> 14 & 0x7fff);
			outputStream.putShortA(optionThree + baseY);
			outputStream.putShort(optionTwo + baseX);
		}
		if (id == 1125) {
			ItemDefinition itemDefinition = ItemDefinition.forID(optionOne);
			String indefinite = "a";
			Interface iComponent = Interface.interfaceCache[optionThree];
			String s5;
			if ((iComponent != null) && (iComponent.invStackSizes[optionTwo] >= 100000)) {
				s5 = iComponent.invStackSizes[optionTwo] + " x " + itemDefinition.name;
			} else if (itemDefinition.description != null) {
				s5 = new String(itemDefinition.description);
			} else {
				if ((itemDefinition.name.charAt(0) == 'A')
				|| (itemDefinition.name.charAt(0) == 'E') || (itemDefinition.name.charAt(0) == 'I')
				|| (itemDefinition.name.charAt(0) == 'O') || (itemDefinition.name.charAt(0) == 'U')) {
					indefinite = "an";
				}
				s5 = "It's " + indefinite + " " + itemDefinition.name + ".";
			}
			pushMessage(s5, 0, "");
		}
		if (id == 1226) {
			int j1 = optionOne >> 14 & 0x7fff;
			ObjectDefinition objectDefinition = ObjectDefinition.forID(j1);
			String examineInfo;
			String indefinite = "a";
			if (objectDefinition.description != null) {
				examineInfo = new String(objectDefinition.description);
			} else {
				if ((objectDefinition.name.charAt(0) == 'A')
				|| (objectDefinition.name.charAt(0) == 'E')
				|| (objectDefinition.name.charAt(0) == 'I')
				|| (objectDefinition.name.charAt(0) == 'O')
				|| (objectDefinition.name.charAt(0) == 'U')) {
					indefinite = "an";
				}
				examineInfo = "It's " + indefinite + " " + objectDefinition.name + ".";
			}
			pushMessage(examineInfo, 0, "");
		}
		if (id == 1448) {
			ItemDefinition itemDefinition = ItemDefinition.forID(optionOne);
			String examineInfo;
			String indefinite = "a";
			if (itemDefinition.description != null) {
				examineInfo = new String(itemDefinition.description);
			} else {
				if ((itemDefinition.name.charAt(0) == 'A')
				|| (itemDefinition.name.charAt(0) == 'E') || (itemDefinition.name.charAt(0) == 'I')
				|| (itemDefinition.name.charAt(0) == 'O') || (itemDefinition.name.charAt(0) == 'U')) {
					indefinite = "an";
				}
				examineInfo = "It's " + indefinite + " " + itemDefinition.name + ".";
			}
			pushMessage(examineInfo, 0, "");
		}
		/**
		 * Run orb.
		 */
		if (id == 1449) {
			//sendPacket185(isRunning ? 153 : 152, 173, 646);
			if (interfaceIsSelected(Interface.interfaceCache[153]) == true) {
				isRunning = false;
				sendPacket185(152, 173, 646);
			} else if (interfaceIsSelected(Interface.interfaceCache[152]) == true) {
				isRunning = true;
				sendPacket185(153, 173, 646);
			}
		}
		/**
		 * View all.
		 */
		if (id == 1450) {
			chatTypeView = 0;
			Client.inputTaken = true;
			for (int chatType = 0; chatType < flashRequest.length; chatType++) {
				flashRequest[chatType] = false;
			}
			for (int chatType = 0; chatType < newTextDrawn.length; chatType++) {
				newTextDrawn[chatType] = false;
			}
			for (int chatType = 0; chatType < flashCount.length; chatType++) {
				pauseFlash[chatType] = false;
				flashCount[chatType] = 4;
			}
		}
		/**
		 * View game.
		 */
		if (id == 1451) {
			chatTypeView = 1;
			Client.inputTaken = true;
			newTextDrawn[0] = false;
			pauseFlash[0] = false;
			flashCount[0] = 4;
			flashRequest[0] = false;
		}
		/**
		 * View public.
		 */
		if (id == 1452) {
			chatTypeView = 2;
			Client.inputTaken = true;
			newTextDrawn[1] = false;
			flashRequest[1] = false;
			pauseFlash[1] = false;
			flashCount[1] = 4;
		}
		/**
		 * Public on.
		 */
		if (id == 1453) {
			publicChatMode = 0;
			Client.inputTaken = true;
		}
		/**
		 * Public friends.
		 */
		if (id == 1454) {
			publicChatMode = 1;
			Client.inputTaken = true;
		}
		/**
		 * Public off.
		 */
		if (id == 1455) {
			publicChatMode = 2;
			Client.inputTaken = true;
		}
		/**
		 * Public hide.
		 */
		if (id == 1456) {
			publicChatMode = 3;
			Client.inputTaken = true;
		}
		/**
		 * View private.
		 */
		if (id == 1457) {
			chatTypeView = 3;
			Client.inputTaken = true;
			pauseFlash[2] = false;
			flashCount[2] = 4;
			newTextDrawn[2] = false;
			flashRequest[2] = false;
		}
		/**
		 * Private on.
		 */
		if (id == 1458) {
			privateChatMode = 0;
			Client.inputTaken = true;
		}
		/**
		 * Private friends.
		 */
		if (id == 1459) {
			privateChatMode = 1;
			Client.inputTaken = true;
		}
		/**
		 * Private off.
		 */
		if (id == 1460) {
			privateChatMode = 2;
			Client.inputTaken = true;
		}
		/**
		 * View clan.
		 */
		if (id == 1461) {
			chatTypeView = 4;
			Client.inputTaken = true;
			pauseFlash[3] = false;
			flashCount[3] = 4;
			newTextDrawn[3] = false;
			flashRequest[3] = false;
		}
		/**
		 * Clan on.
		 */
		if (id == 1462) {
			clanChatMode = 0;
			Client.inputTaken = true;
		}
		/**
		 * Clan friends.
		 */
		if (id == 1463) {
			clanChatMode = 1;
			Client.inputTaken = true;
		}
		/**
		 * Clan off.
		 */
		if (id == 1464) {
			clanChatMode = 2;
			Client.inputTaken = true;
		}
		/**
		 * View trade.
		 */
		if (id == 1465) {
			chatTypeView = 5;
			Client.inputTaken = true;
			pauseFlash[4] = false;
			flashCount[4] = 4;
			newTextDrawn[4] = false;
			flashRequest[4] = false;
		}
		/**
		 * Trade on.
		 */
		if (id == 1466) {
			tradeMode = 0;
			Client.inputTaken = true;
		}
		/**
		 * Trade friends.
		 */
		if (id == 1467) {
			tradeMode = 1;
			Client.inputTaken = true;
		}
		/**
		 * Trade off.
		 */
		if (id == 1468) {
			tradeMode = 2;
			Client.inputTaken = true;
		}
		/**
		 * View assist.
		 */
		if (id == 1469) {
			chatTypeView = 6;
			Client.inputTaken = true;
			pauseFlash[5] = false;
			flashCount[5] = 4;
			newTextDrawn[5] = false;
			flashRequest[5] = false;
		}
		/**
		 * Assist on.
		 */
		if (id == 1470) {
			assistMode = 0;
			Client.inputTaken = true;
		}
		/**
		 * Assist friends.
		 */
		if (id == 1471) {
			assistMode = 1;
			Client.inputTaken = true;
		}
		/**
		 * Assist off.
		 */
		if (id == 1472) {
			assistMode = 2;
			Client.inputTaken = true;
		}
		itemSelected = 0;
		spellSelected = 0;
		drawInventoryRequest = true;
	}

	private void doFlamesDrawing() {
		char c = '\u0100';
		if (anInt1040 > 0) {
			for (int i = 0; i < 256; i++) {
				if (anInt1040 > 768) {
					anIntArray850[i] = method83(anIntArray851[i], anIntArray852[i],
					1024 - anInt1040);
				} else if (anInt1040 > 256) {
					anIntArray850[i] = anIntArray852[i];
				} else {
					anIntArray850[i] = method83(anIntArray852[i], anIntArray851[i], 256 - anInt1040);
				}
			}
		} else if (anInt1041 > 0) {
			for (int j = 0; j < 256; j++) {
				if (anInt1041 > 768) {
					anIntArray850[j] = method83(anIntArray851[j], anIntArray853[j],
					1024 - anInt1041);
				} else if (anInt1041 > 256) {
					anIntArray850[j] = anIntArray853[j];
				} else {
					anIntArray850[j] = method83(anIntArray853[j], anIntArray851[j], 256 - anInt1041);
				}
			}
		} else {
			System.arraycopy(anIntArray851, 0, anIntArray850, 0, 256);
		}
		System.arraycopy(leftFlame.pixels, 0, leftFlameCanvas.componentPixels, 0, 33920);
		int i1 = 0;
		int j1 = 1152;
		for (int k1 = 1; k1 < c - 1; k1++) {
			int l1 = (anIntArray969[k1] * (c - k1)) / c;
			int j2 = 22 + l1;
			if (j2 < 0) {
				j2 = 0;
			}
			i1 += j2;
			for (int l2 = j2; l2 < 128; l2++) {
				int j3 = anIntArray828[i1++];
				if (j3 != 0) {
					int l3 = j3;
					int j4 = 256 - j3;
					j3 = anIntArray850[j3];
					int l4 = leftFlameCanvas.componentPixels[j1];
					leftFlameCanvas.componentPixels[j1++] = ((j3 & 0xff00ff) * l3 + (l4 & 0xff00ff)
					* j4 & 0xff00ff00)
					+ ((j3 & 0xff00) * l3 + (l4 & 0xff00) * j4 & 0xff0000) >> 8;
				} else {
					j1++;
				}
			}
			j1 += j2;
		}
		leftFlameCanvas.drawGraphics(super.graphics, 0, 0);
		System.arraycopy(rightFlame.pixels, 0, rightFlameCanvas.componentPixels, 0, 33920);
		i1 = 0;
		j1 = 1176;
		for (int k2 = 1; k2 < c - 1; k2++) {
			int i3 = (anIntArray969[k2] * (c - k2)) / c;
			int k3 = 103 - i3;
			j1 += i3;
			for (int i4 = 0; i4 < k3; i4++) {
				int k4 = anIntArray828[i1++];
				if (k4 != 0) {
					int i5 = k4;
					int j5 = 256 - k4;
					k4 = anIntArray850[k4];
					int k5 = rightFlameCanvas.componentPixels[j1];
					rightFlameCanvas.componentPixels[j1++] = ((k4 & 0xff00ff) * i5
					+ (k5 & 0xff00ff) * j5 & 0xff00ff00)
					+ ((k4 & 0xff00) * i5 + (k5 & 0xff00) * j5 & 0xff0000) >> 8;
				} else {
					j1++;
				}
			}
			i1 += 128 - k3;
			j1 += 128 - k3 - i3;
		}
		rightFlameCanvas.drawGraphics(super.graphics, 637, 0);
	}

	private boolean doWalkTo(int i, int j, int k, int i1, int j1, int k1, int l1, int i2, int j2,
	boolean flag, int k2) {
		byte byte0 = 104;
		byte byte1 = 104;
		for (int l2 = 0; l2 < byte0; l2++) {
			for (int i3 = 0; i3 < byte1; i3++) {
				anIntArrayArray901[l2][i3] = 0;
				anIntArrayArray825[l2][i3] = 99999999;
			}
		}
		int j3 = j2;
		int k3 = j1;
		anIntArrayArray901[j2][j1] = 99;
		anIntArrayArray825[j2][j1] = 0;
		int l3 = 0;
		int i4 = 0;
		bigX[l3] = j2;
		bigY[l3++] = j1;
		boolean flag1 = false;
		int j4 = bigX.length;
		int ai[][] = collisionMap[plane].collisionFlags;
		while (i4 != l3) {
			j3 = bigX[i4];
			k3 = bigY[i4];
			i4 = (i4 + 1) % j4;
			if ((j3 == k2) && (k3 == i2)) {
				flag1 = true;
				break;
			}
			if (i1 != 0) {
				if (((i1 < 5) || (i1 == 10))
				&& collisionMap[plane].isWalkableWall(i1 - 1, j, k2, j3, i2, k3)) {
					flag1 = true;
					break;
				}
				if ((i1 < 10)
				&& collisionMap[plane].isWalkableDiagonalWall(i1 - 1, j, k2, j3, i2, k3)) {
					flag1 = true;
					break;
				}
			}
			if ((k1 != 0) && (k != 0) && collisionMap[plane].method221(k2, j3, i2, k3, k, l1, k1)) {
				flag1 = true;
				break;
			}
			int l4 = anIntArrayArray825[j3][k3] + 1;
			if ((j3 > 0) && (anIntArrayArray901[j3 - 1][k3] == 0)
			&& ((ai[j3 - 1][k3] & 0x1280108) == 0)) {
				bigX[l3] = j3 - 1;
				bigY[l3] = k3;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3 - 1][k3] = 2;
				anIntArrayArray825[j3 - 1][k3] = l4;
			}
			if ((j3 < byte0 - 1) && (anIntArrayArray901[j3 + 1][k3] == 0)
			&& ((ai[j3 + 1][k3] & 0x1280180) == 0)) {
				bigX[l3] = j3 + 1;
				bigY[l3] = k3;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3 + 1][k3] = 8;
				anIntArrayArray825[j3 + 1][k3] = l4;
			}
			if ((k3 > 0) && (anIntArrayArray901[j3][k3 - 1] == 0)
			&& ((ai[j3][k3 - 1] & 0x1280102) == 0)) {
				bigX[l3] = j3;
				bigY[l3] = k3 - 1;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3][k3 - 1] = 1;
				anIntArrayArray825[j3][k3 - 1] = l4;
			}
			if ((k3 < byte1 - 1) && (anIntArrayArray901[j3][k3 + 1] == 0)
			&& ((ai[j3][k3 + 1] & 0x1280120) == 0)) {
				bigX[l3] = j3;
				bigY[l3] = k3 + 1;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3][k3 + 1] = 4;
				anIntArrayArray825[j3][k3 + 1] = l4;
			}
			if ((j3 > 0) && (k3 > 0) && (anIntArrayArray901[j3 - 1][k3 - 1] == 0)
			&& ((ai[j3 - 1][k3 - 1] & 0x128010e) == 0) && ((ai[j3 - 1][k3] & 0x1280108) == 0)
			&& ((ai[j3][k3 - 1] & 0x1280102) == 0)) {
				bigX[l3] = j3 - 1;
				bigY[l3] = k3 - 1;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3 - 1][k3 - 1] = 3;
				anIntArrayArray825[j3 - 1][k3 - 1] = l4;
			}
			if ((j3 < byte0 - 1) && (k3 > 0) && (anIntArrayArray901[j3 + 1][k3 - 1] == 0)
			&& ((ai[j3 + 1][k3 - 1] & 0x1280183) == 0) && ((ai[j3 + 1][k3] & 0x1280180) == 0)
			&& ((ai[j3][k3 - 1] & 0x1280102) == 0)) {
				bigX[l3] = j3 + 1;
				bigY[l3] = k3 - 1;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3 + 1][k3 - 1] = 9;
				anIntArrayArray825[j3 + 1][k3 - 1] = l4;
			}
			if ((j3 > 0) && (k3 < byte1 - 1) && (anIntArrayArray901[j3 - 1][k3 + 1] == 0)
			&& ((ai[j3 - 1][k3 + 1] & 0x1280138) == 0) && ((ai[j3 - 1][k3] & 0x1280108) == 0)
			&& ((ai[j3][k3 + 1] & 0x1280120) == 0)) {
				bigX[l3] = j3 - 1;
				bigY[l3] = k3 + 1;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3 - 1][k3 + 1] = 6;
				anIntArrayArray825[j3 - 1][k3 + 1] = l4;
			}
			if ((j3 < byte0 - 1) && (k3 < byte1 - 1) && (anIntArrayArray901[j3 + 1][k3 + 1] == 0)
			&& ((ai[j3 + 1][k3 + 1] & 0x12801e0) == 0) && ((ai[j3 + 1][k3] & 0x1280180) == 0)
			&& ((ai[j3][k3 + 1] & 0x1280120) == 0)) {
				bigX[l3] = j3 + 1;
				bigY[l3] = k3 + 1;
				l3 = (l3 + 1) % j4;
				anIntArrayArray901[j3 + 1][k3 + 1] = 12;
				anIntArrayArray825[j3 + 1][k3 + 1] = l4;
			}
		}
		anInt1264 = 0;
		if (!flag1) {
			if (flag) {
				int i5 = 100;
				for (int k5 = 1; k5 < 2; k5++) {
					for (int i6 = k2 - k5; i6 <= k2 + k5; i6++) {
						for (int l6 = i2 - k5; l6 <= i2 + k5; l6++) {
							if ((i6 >= 0) && (l6 >= 0) && (i6 < 104) && (l6 < 104)
							&& (anIntArrayArray825[i6][l6] < i5)) {
								i5 = anIntArrayArray825[i6][l6];
								j3 = i6;
								k3 = l6;
								anInt1264 = 1;
								flag1 = true;
							}
						}
					}
					if (flag1) {
						break;
					}
				}
			}
			if (!flag1) {
				return false;
			}
		}
		i4 = 0;
		bigX[i4] = j3;
		bigY[i4++] = k3;
		int l5;
		for (int j5 = l5 = anIntArrayArray901[j3][k3]; (j3 != j2) || (k3 != j1); j5 = anIntArrayArray901[j3][k3]) {
			if (j5 != l5) {
				l5 = j5;
				bigX[i4] = j3;
				bigY[i4++] = k3;
			}
			if ((j5 & 2) != 0) {
				j3++;
			} else if ((j5 & 8) != 0) {
				j3--;
			}
			if ((j5 & 1) != 0) {
				k3++;
			} else if ((j5 & 4) != 0) {
				k3--;
			}
		}
		// if(cancelWalk) { return i4 > 0; }
		if (i4 > 0) {
			int k4 = i4;
			if (k4 > 25) {
				k4 = 25;
			}
			i4--;
			int k6 = bigX[i4];
			int i7 = bigY[i4];
			Client.anInt1288 += k4;
			if (Client.anInt1288 >= 92) {
				outputStream.putOperation(36);
				outputStream.putInt(0);
				Client.anInt1288 = 0;
			}
			if (i == 0) {
				outputStream.putOperation(164);
				outputStream.putByte(k4 + k4 + 3);
			}
			if (i == 1) {
				outputStream.putOperation(248);
				outputStream.putByte(k4 + k4 + 3 + 14);
			}
			if (i == 2) {
				outputStream.putOperation(98);
				outputStream.putByte(k4 + k4 + 3);
			}
			outputStream.putLEShortA(k6 + baseX);
			destX = bigX[0];
			destY = bigY[0];
			for (int j7 = 1; j7 < k4; j7++) {
				i4--;
				outputStream.putByte(bigX[i4] - k6);
				outputStream.putByte(bigY[i4] - i7);
			}
			outputStream.putLEShort(i7 + baseY);
			outputStream.putByteC(super.keyArray[5] != 1 ? 0 : 1);
			return true;
		}
		return i != 1;
	}

	private void draw3dScreen() {
		if (consoleOpen) {
			drawConsole();
		} else {
			consoleAlpha = 0;
		}
		drawSplitPrivateChat();
		if (crossType == 1) {
			crosses[crossIndex / 100].drawSprite(crossX - 8 - 4, crossY - 8 - 4);
			Client.anInt1142++;
			if (Client.anInt1142 > 67) {
				Client.anInt1142 = 0;
				outputStream.putOperation(78);
			}
		}
		if (crossType == 2) {
			crosses[4 + crossIndex / 100].drawSprite(crossX - 8 - 4, crossY - 8 - 4);
		}
		if (anInt1018 != -1) {
			method119(anInt945, anInt1018);
			drawInterface(0, 0, Interface.interfaceCache[anInt1018], 0);
		}
		if (openInterfaceID != -1) {
			method119(anInt945, openInterfaceID);
			drawInterface(0, 0, Interface.interfaceCache[openInterfaceID], 0);
		}
		method70();
		if (!menuOpen) {
			processRightClick();
			drawTooltip();
		} else if (menuOpen) {
			drawMenu(4, 0);
		}
		if (anInt1055 == 1) {
			headIcons_prayer[1].drawSprite(472, 296);
		}
		if (Client.fpsOn == true) {
			int color = 0xffff00;
			if (super.fps < 15) {
				color = 0xff0000;
			}
			plainText.drawLeftAlignedText("Fps: " + super.fps, 507, 20, color);
			Runtime runtime = Runtime.getRuntime();
			int memory = (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024L);
			color = 0xffff00;
			if ((memory > 0x2000000) && Client.lowMem) {
				color = 0xff0000;
			}
			plainText.drawLeftAlignedText("Mem: " + memory + "k", 507, 35, 0xffff00);
			plainText.drawLeftAlignedText("Mouse X: " + super.mouseX + " , Mouse Y: "
			+ super.mouseY, 39, 50, 0xffff00);
			int x = baseX + (Client.myPlayer.x - 6 >> 7);
			int y = baseY + (Client.myPlayer.y - 6 >> 7);
			plainText.drawLeftAlignedText("Coords: " + x + ", " + y, 507, 65, 0xffff00);
		}
		if (anInt1104 != 0) {
			int j = anInt1104 / 50;
			int l = j / 60;
			j %= 60;
			if (j < 10) {
				plainText.drawText("System update in: " + l + ":0" + j, 4, 329, 0xffff00);
			} else {
				plainText.drawText("System update in: " + l + ":" + j, 4, 329, 0xffff00);
			}
			Client.anInt849++;
			if (Client.anInt849 > 75) {
				Client.anInt849 = 0;
				outputStream.putOperation(148);
			}
		}
	}

	public void drawFilterButtons() {
		for (int count = 0; count < 6; count++) {
			if (flashCount[count] == 0) {
				pauseFlash[count] = true;
			}
		}
		String text[] = { "On", "Friends", "Off", "Hide" };
		int textColor[] = { 65280, 0xffff00, 0xff0000, 65535 };
		/**
		 * "All" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 0) {
				if (chatFilterHover == 0) {
					filterButtons[4].drawSprite(5, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(5, 143);// Clicked
				}
			} else {
				if (chatFilterHover == 0) {
					filterButtons[1].drawSprite(5, 143);// Hover
				} else {
					filterButtons[0].drawSprite(5, 143);// Default
				}
			}
		} else {
			if (chatTypeView == 0) {
				if (chatFilterHover == 0) {
					filterButtons[4].drawSprite(5, 142);
				} else {
					filterButtons[3].drawSprite(5, 142);
				}
			} else {
				if (chatFilterHover == 0) {
					filterButtons[1].drawSprite(5, 142);
				} else {
					filterButtons[0].drawSprite(5, 142);
				}
			}
		}
		/**
		 * "Game" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 1) {
				if (chatFilterHover == 1) {
					filterButtons[4].drawSprite(62, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(62, 143);// Clicked
				}
			} else {
				if (chatFilterHover != 1) {
					/**
					 * Checks if new text is drawn while player is not viewing
					 * "Game"
					 */
					if ((flashRequest[0] && (Client.loopCycle % 60 < 30)) || pauseFlash[0]) {
						/**
						 * Subtracts flash times if the flashing button has not
						 * paused yet
						 */
						if (!pauseFlash[0]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[0]--;
							}
						}
						filterButtons[2].drawSprite(62, 143);// Flash
					} else {
						filterButtons[0].drawSprite(62, 143);// Default
					}
				} else {
					filterButtons[1].drawSprite(62, 143);// Hover
				}
			}
		} else {
			if (chatTypeView == 1) {
				if (chatFilterHover == 1) {
					filterButtons[4].drawSprite(71, 142);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(71, 142);// Clicked
				}
			} else {
				if (chatFilterHover != 1) {
					if ((flashRequest[0] && (Client.loopCycle % 60 < 30)) || pauseFlash[0]) {
						if (!pauseFlash[0]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[0]--;
							}
						}
						filterButtons[2].drawSprite(71, 142);
					} else {
						filterButtons[0].drawSprite(71, 142);
					}
				} else {
					filterButtons[1].drawSprite(71, 142);
				}
			}
		}
		/**
		 * "Public" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 2) {
				if (chatFilterHover == 2) {
					filterButtons[4].drawSprite(119, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(119, 143);// Clicked
				}
			} else {
				if (chatFilterHover != 2) {
					if ((flashRequest[1] && (Client.loopCycle % 60 < 30)) || pauseFlash[1]) {
						if (!pauseFlash[1]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[1]--;
							}
						}
						filterButtons[2].drawSprite(119, 143);// Flash
					} else {
						filterButtons[0].drawSprite(119, 143);// Default
					}
				} else {
					filterButtons[1].drawSprite(119, 143);// Hover
				}
			}
		} else {
			if (chatTypeView == 2) {
				if (chatFilterHover == 2) {
					filterButtons[4].drawSprite(137, 142);
				} else {
					filterButtons[3].drawSprite(137, 142);
				}
			} else {
				if (chatFilterHover != 2) {
					if ((flashRequest[1] && (Client.loopCycle % 60 < 30)) || pauseFlash[1]) {
						if (!pauseFlash[1]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[1]--;
							}
						}
						filterButtons[2].drawSprite(137, 142);
					} else {
						filterButtons[0].drawSprite(137, 142);
					}
				} else {
					filterButtons[1].drawSprite(137, 142);
				}
			}
		}
		/**
		 * "Private" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 3) {
				if (chatFilterHover == 3) {
					filterButtons[4].drawSprite(176, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(176, 143);// Clicked
				}
			} else {
				if (chatFilterHover != 3) {
					if ((flashRequest[2] && (Client.loopCycle % 60 < 30)) || pauseFlash[2]) {
						if (!pauseFlash[2]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[2]--;
							}
						}
						filterButtons[2].drawSprite(176, 143);// Flash
					} else {
						filterButtons[0].drawSprite(176, 143);// Default
					}
				} else {
					filterButtons[1].drawSprite(176, 143);// Hover
				}
			}
		} else {
			if (chatTypeView == 3) {
				if (chatFilterHover == 3) {
					filterButtons[4].drawSprite(203, 142);
				} else {
					filterButtons[3].drawSprite(203, 142);
				}
			} else {
				if (chatFilterHover != 3) {
					if ((flashRequest[2] && (Client.loopCycle % 60 < 30)) || pauseFlash[2]) {
						if (!pauseFlash[2]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[2]--;
							}
						}
						filterButtons[2].drawSprite(203, 142);
					} else {
						filterButtons[0].drawSprite(203, 142);
					}
				} else {
					filterButtons[1].drawSprite(203, 142);
				}
			}
		}
		/**
		 * "Clan" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 4) {
				if (chatFilterHover == 4) {
					filterButtons[4].drawSprite(233, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(233, 143);// Clicked
				}
			} else {
				if (chatFilterHover != 4) {
					if ((flashRequest[3] && (Client.loopCycle % 60 < 30)) || pauseFlash[3]) {
						if (!pauseFlash[3]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[3]--;
							}
						}
						filterButtons[2].drawSprite(233, 143);// Flash
					} else {
						filterButtons[0].drawSprite(233, 143);// Default
					}
				} else {
					filterButtons[1].drawSprite(233, 143);// Hover
				}
			}
		} else {
			if (chatTypeView == 4) {
				if (chatFilterHover == 4) {
					filterButtons[4].drawSprite(269, 142);
				} else {
					filterButtons[3].drawSprite(269, 142);
				}
			} else {
				if (chatFilterHover != 4) {
					if ((flashRequest[3] && (Client.loopCycle % 60 < 30)) || pauseFlash[3]) {
						if (!pauseFlash[3]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[3]--;
							}
						}
						filterButtons[2].drawSprite(269, 142);
					} else {
						filterButtons[0].drawSprite(269, 142);
					}
				} else {
					filterButtons[1].drawSprite(269, 142);
				}
			}
		}
		/**
		 * "Trade" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 5) {
				if (chatFilterHover == 5) {
					filterButtons[4].drawSprite(290, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(290, 143);// Clicked
				}
			} else {
				if (chatFilterHover != 5) {
					if ((flashRequest[4] && (Client.loopCycle % 60 < 30)) || pauseFlash[4]) {
						if (!pauseFlash[4]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[4]--;
							}
						}
						filterButtons[2].drawSprite(290, 143);// Flash
					} else {
						filterButtons[0].drawSprite(290, 143);// Default
					}
				} else {
					filterButtons[1].drawSprite(290, 143);// Hover
				}
			}
		} else {
			if (chatTypeView == 5) {
				if (chatFilterHover == 5) {
					filterButtons[4].drawSprite(335, 142);
				} else {
					filterButtons[3].drawSprite(335, 142);
				}
			} else {
				if (chatFilterHover != 5) {
					if ((flashRequest[4] && (Client.loopCycle % 60 < 30)) || pauseFlash[4]) {
						if (!pauseFlash[4]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[4]--;
							}
						}
						filterButtons[2].drawSprite(335, 142);
					} else {
						filterButtons[0].drawSprite(335, 142);
					}
				} else {
					filterButtons[1].drawSprite(335, 142);
				}
			}
		}
		/**
		 * "Assist" button
		 */
		if (VERSION > 474) {
			if (chatTypeView == 6) {
				if (chatFilterHover == 6) {
					filterButtons[4].drawSprite(347, 143);// Hover & Clicked
				} else {
					filterButtons[3].drawSprite(347, 143);// Clicked
				}
			} else {
				if (chatFilterHover != 6) {
					if ((flashRequest[5] && (Client.loopCycle % 60 < 30)) || pauseFlash[5]) {
						if (!pauseFlash[5]) {
							if (System.currentTimeMillis() - flashRate > 1000) {
								flashRate = System.currentTimeMillis();
								flashCount[5]--;
							}
						}
						filterButtons[2].drawSprite(347, 143);// Flash
					} else {
						filterButtons[0].drawSprite(347, 143);// Default
					}
				} else {
					filterButtons[1].drawSprite(347, 143);// Hover
				}
			}
		}
		if (VERSION > 474) {
			if (chatFilterHover == 7) {
				filterButtons[6].drawSprite(404, 143);// Report Abuse Hover
			} else {
				filterButtons[5].drawSprite(404, 143);// Report Abuse
			}
		} else {
			if (chatFilterHover == 7) {
				filterButtons[6].drawSprite(404, 142);
			} else {
				filterButtons[5].drawSprite(404, 142);
			}
		}
		if (VERSION > 474) {
			smallText.drawText("All", 26, 158, 0xffffff, true);
			smallText.drawText("Game", 77, 158, 0xffffff, true);
			smallText.drawText("Public", 132, 153, 0xffffff, true);
			smallText.drawText("Private", 185, 153, 0xffffff, true);
			smallText.drawText("Clan", 250, 153, 0xffffff, true);
			smallText.drawText("Trade", 304, 153, 0xffffff, true);
			smallText.drawText("Assist", 359, 153, 0xffffff, true);
			smallText.drawText("Report Abuse", 425, 158, 0xffffff, true);
			smallText.drawCenteredText(text[publicChatMode], 146, 164, textColor[publicChatMode],
			true);
			smallText.drawCenteredText(text[privateChatMode], 203, 164, textColor[privateChatMode],
			true);
			smallText.drawCenteredText(text[clanChatMode], 260, 164, textColor[clanChatMode], true);
			smallText.drawCenteredText(text[tradeMode], 317, 164, textColor[tradeMode], true);
			smallText.drawCenteredText(text[assistMode], 374, 164, textColor[assistMode], true);
		} else {
			smallText.drawText("All", 26, 157, 0xffffff, true);
			smallText.drawText("Game", 86, 157, 0xffffff, true);
			smallText.drawText("Public", 150, 152, 0xffffff, true);
			smallText.drawText("Private", 212, 152, 0xffffff, true);
			smallText.drawText("Clan", 286, 152, 0xffffff, true);
			smallText.drawText("Trade", 349, 152, 0xffffff, true);
			smallText.drawText("Report Abuse", 425, 157, 0xffffff, true);
			smallText.drawCenteredText(text[publicChatMode], 164, 163, textColor[publicChatMode],
			true);
			smallText.drawCenteredText(text[privateChatMode], 230, 163, textColor[privateChatMode],
			true);
			smallText.drawCenteredText(text[clanChatMode], 296, 163, textColor[clanChatMode], true);
			smallText.drawCenteredText(text[tradeMode], 362, 163, textColor[tradeMode], true);
		}
	}

	/**
	 * Draws the player's general chat area.
	 * The player's input is processed here.
	 * The chat filter, along with crowns, are also handled here.
	 */
	private void drawChatbox() {
		chatboxCanvas.init();
		Renderer3D.lineOffsets = chatboxTexturePool;
		chatBox[getImageId()].drawSprite(0, 0);
		drawFilterButtons();
		Font plainText = this.plainText;
		if (messagePromptRaised) { // Checks to see if there is a chatbox interface.
			boldText.drawCenteredText(messagePromptTitle, 259, 68, 0);
			boldText.drawCenteredText(promptInput + "*", 259, 97, 128);
		} else if (inputDialogState == 1) {
			boldText.drawCenteredText("Enter amount:", 259, 68, 0);
			boldText.drawCenteredText(amountOrNameInput + "*", 259, 97, 128);
		} else if (inputDialogState == 2) {
			boldText.drawCenteredText("Enter name:", 259, 68, 0);
			boldText.drawCenteredText(amountOrNameInput + "*", 259, 97, 128);
		} else if (continueMessageTitle != null) {
			boldText.drawCenteredText(continueMessageTitle, 259, 68, 0);
			boldText.drawCenteredText("Click to continue", 259, 97, 128);
		} else if (backDialogID != -1) {
			drawInterface(0, 16, Interface.interfaceCache[backDialogID], 24);
		} else if (dialogID != -1) {
			drawInterface(0, 16, Interface.interfaceCache[dialogID], 24);
		} else {
			int messages = 0;
			Renderer2D.setDrawingArea(8, 7, 498, 122);
			for (int messageCount = 0; messageCount < 100; messageCount++) {
				if (chatMessages[messageCount] != null) {
					int inputId = chatTypes[messageCount];
					int x; // The x position of the text.
					int y = (117 - messages * 14) + Client.scrollerPosition; // The y position of the text.
					if (VERSION > 484) {
						y -= 1;
					}
					String name = chatNames[messageCount]; // Represents a single player's name.
					byte playerRights = 0; // The player's privileges.
					if ((name != null) && name.startsWith("@cr1@")) { // Gets the player's priviliges based on the crown.
						name = name.substring(5);
						playerRights = 1;
					}
					if ((name != null) && name.startsWith("@cr2@")) {
						name = name.substring(5);
						playerRights = 2;
					}
					if ((chatTypeView == 0) || (chatTypeView == 1)) { // Sends "Game" type messages.
						if (inputId == 0) {
							if ((y > 0) && (y < 130)) {
								x = 10;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								plainText.drawText(chatMessages[messageCount], x, y, 0);
							}
							messages++;
						}
					} else {
						if (newTextDrawn[0] == true) {
							flashRequest[0] = true;
						}
					}
					if ((chatTypeView == 0) || (chatTypeView == 2)) { // Sends "Public" type messages.
						if ((inputId == 1) || ((inputId == 2) && (publicChatMode == 0))
						|| ((publicChatMode == 1) && isFriendOrSelf(name))) {
							if ((y > 0) && (y < 130)) {
								x = 10;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								if (playerRights == 1) {
									modIcons[0].drawIndexedSprite(x, y - 12);
									x += 12;
								}
								if (playerRights == 2) {
									modIcons[1].drawIndexedSprite(x, y - 12);
									x += 12;
								}
								plainText.drawText(name + ":", x, y, 0);
								x += plainText.getTextWidth(name + 8);
								plainText.drawText(chatMessages[messageCount], x - 2, y, 255);
							}
							messages++;
						}
					} else {
						if (newTextDrawn[1] == true) { // Sends the flash request if the player isn't viewing the chat.
							flashRequest[1] = true;
						}
					}
					if ((chatTypeView == 0) || (chatTypeView == 3)) { // Sends "Private" type messages.
						if ((inputId == 3) // Private messages from another player.
						|| ((inputId == 7) && (splitPrivateChat == 0) && (privateChatMode == 0))
						|| ((privateChatMode == 1) && isFriendOrSelf(name))) {
							if ((y > 0) || (y < 130)) {
								x = 11;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								plainText.drawText("From", x, y, 0);
								x += plainText.getTextWidth("From ");
								if (playerRights == 1) {
									modIcons[0].drawIndexedSprite(x, y - 12);
									x += 12;
								}
								if (playerRights == 2) {
									modIcons[1].drawIndexedSprite(x, y - 12);
									x += 12;
								}
								plainText.drawText(name + ":", x, y, 0);
								x += plainText.getTextWidth(name + 7);
								plainText.drawText(chatMessages[messageCount], x, y, 0x800000);
							}
							messages++;
						}
						if ((inputId == 5) && (privateChatMode < 2)) { // Message sent when a friend logs on or off.
							if ((y > 0) || (y < 130)) {
								x = 11;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								plainText.drawText(chatMessages[messageCount], x, y, 0x800000);
							}
							messages++;
						}
						if (((inputId == 6) && (splitPrivateChat == 0) && (privateChatMode == 0))
						|| ((privateChatMode == 1) && isFriendOrSelf(name))) { // Private messages recieved from a player.
							if ((y > 0) || (y < 130)) {
								x = 11;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								plainText.drawText("To " + name + ":", x, y, 0);
								plainText.drawText(chatMessages[messageCount], 32 + plainText
								.getTextWidth(name), y, 0x800000);
							}
							messages++;
						}
					} else {
						if (newTextDrawn[2] == true) {
							flashRequest[2] = true;
						}
					}
					if ((chatTypeView == 0) || (chatTypeView == 4)) { // Sends "Clan" messages.
						// TODO: Clan chat system.
					} else {
						if (newTextDrawn[3] == true) {
							flashRequest[3] = true;
						}
					}
					if ((chatTypeView == 0) || (chatTypeView == 5)) { // Sends "Trade" messages (trade/duel requests).
						if (((inputId == 4) && (tradeMode == 0))
						|| ((tradeMode == 1) && isFriendOrSelf(name))) { // Trade requests from another player.
							if ((y > 0) || (y < 130)) {
								x = 10;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								plainText.drawText(name + " " + chatMessages[messageCount], x, y,
								0x800080);
							}
							messages++;
						}
						if (((inputId == 8) && (tradeMode == 0))
						|| ((tradeMode == 1) && isFriendOrSelf(name))) { // Duel requests from another player.
							if ((y > 0) || (y < 130)) {
								x = 10;
								if (VERSION > 484) {
									x -= 1;
								}
								if (VERSION == 474) {
									x += 1;
								}
								plainText.drawText(name + " " + chatMessages[messageCount], x, y,
								0x7e3200);
							}
							messages++;
						}
					} else {
						if (newTextDrawn[4] == true) {
							flashRequest[4] = true;
						}
					}
					if ((chatTypeView == 0) || (chatTypeView == 6)) { // Sends "Assist" requests.
						// TODO: Assist system.
					} else {
						if (newTextDrawn[5] == true) {
							flashRequest[5] = true;
						}
					}
				}
			}
			Renderer2D.setDefaultDrawingAreaSize();
			scrollerHeight = messages * 14 + 12;
			if (scrollerHeight < 111) {
				scrollerHeight = 111;
			}
			String fixedName;
			if ((Client.myPlayer != null) && (Client.myPlayer.name != null)) {
				fixedName = Client.myPlayer.name;
			} else {
				fixedName = TextUtil.fixName(myUsername);
			}
			int x = 10;
			int y = 133;
			switch (VERSION) {
				case 474:
					Renderer2D.drawHorizontalLine(8, 121, 503, 0x807660);
					drawScrollBar(496, 7, scrollerHeight - Client.scrollerPosition - 110,
					scrollerHeight + 2, 114);
					x += 1;
					break;
				case 484:
					Renderer2D.drawHorizontalLine(8, 121, 504, 0x807660);
					drawScrollBar(495, 7, scrollerHeight - Client.scrollerPosition - 110,
					scrollerHeight + 2, 114);
					break;
				case 508:
					Renderer2D.drawHorizontalLine(8, 120, 504, 0x807660);
					drawScrollBar(496, 7, scrollerHeight - Client.scrollerPosition - 109,
					scrollerHeight + 1, 113);
					x -= 1;
					y -= 1;
					break;
				case 562:
					Renderer2D.drawHorizontalLine(8, 119, 503, 0, 16);
					Renderer2D.drawHorizontalLine(8, 120, 503, 0x807660);
					drawScrollBar(496, 7, scrollerHeight - Client.scrollerPosition - 109,
					scrollerHeight + 1, 113);
					x -= 1;
					y -= 1;
			}
			plainText.drawText(fixedName + ":", x, y, 0);
			plainText.drawText(inputString + "*", x + plainText.getTextWidth(fixedName + ": "), y,
			255, false);
		}
		if (menuOpen) {
			drawMenu(0, 334);
		}
		chatboxCanvas.drawGraphics(super.graphics, 0, 338);
		gameScreenCanvas.init();
		Renderer3D.lineOffsets = gameScreenTexturePool;
	}

	private void drawConsole() {
		if (consoleOpen) {
			Renderer2D.fillRectangle(0, 0, 512, 334, 0x3c00ff, (consoleAlpha < 40 ? consoleAlpha++
				: (consoleAlpha = 40)));
			Renderer2D.drawHorizontalLine(0, 316, 512, 0xffffff);
			boldText.drawText("-->", 11, 331, 0xffffff, true);
			if (consoleFirstOpened == true) {
				printConsoleMessage("This is the developer console. To close, press the ` key.", 0);
				consoleFirstOpened = false;
			}
			if (Client.loopCycle % 40 < 20) {
				boldText.drawText(consoleInput + "|", 38, 331, 0xffffff, true);
			}
			boldText.drawText(consoleInput, 38, 331, 0xffffff, true);
			for (int messages = 0, y = 310; messages < 17; messages++, y -= 19) {
				plainText.drawText(consoleMessages[messages], 9, y, 0xffffff, true);
			}
		} else {
			consoleAlpha = 0;
		}
	}

	private void printConsoleMessage(String message, int type) {
		Calendar calendar = new GregorianCalendar();
		byte hour = (byte) calendar.get(Calendar.HOUR);
		String seconds = Integer.toString(calendar.get(Calendar.SECOND));
		String minutes = Integer.toString(calendar.get(Calendar.MINUTE));
		if (calendar.get(Calendar.AM_PM) == 1) {
			hour += 12;
		}
		if (calendar.get(Calendar.SECOND) < 10) {
			seconds = "0" + seconds;
		}
		if (calendar.get(Calendar.MINUTE) < 10) {
			seconds = "0" + minutes;
		}
		String time = "" + hour + ":" + minutes + ":" + seconds;
		if (backDialogID == -1) {
			Client.inputTaken = true;
		}
		for (int visible = 16; visible > 0; visible--) {
			consoleMessages[visible] = consoleMessages[visible - 1];
		}
		if (type == 0) {
			consoleMessages[0] = time + " --> " + message;
		} else {
			consoleMessages[0] = time + " " + message;
		}
	}

	private void processConsoleCommand(String input) {
		try {
			String[] args = input.split(" ");
			String command = args[0].toLowerCase();
			if (command.equals("cls")) {
				for (int cleared = 0; cleared < 17; cleared++) {
					consoleMessages[cleared] = null;
				}
			} else if (command.equals("ragequit")) {
				System.exit(0);
			} else if (command.startsWith("interface")) {
				try {
					int fullscreenInterface = Integer.parseInt(args[1]);
					int openInterface = Integer.parseInt(args[2]);
					fullscreenInterfaceID = fullscreenInterface;
					openInterfaceID = openInterface;
					printConsoleMessage("Opened Interface.", 1);
				} catch (Exception e) {
					printConsoleMessage("Interface failed to load.", 1);
				}
			} else if (command.equals("debug")) {
				printDebug();
			} else if (command.equals("prefetchmusic")) {
				for (int j1 = 0; j1 < onDemandFetcher.getVersionCount(2); j1++) {
					onDemandFetcher.method563((byte) 1, 2, j1);
				}
			} else if (command.equals("fps")) {
				Client.fpsOn = !Client.fpsOn;
			} else if (command.equals("noclip")) {
				for (int i = 0; i < 4; i++) {
					for (int x = 1; x < 103; x++) {
						for (int y = 1; y < 103; y++) {
							collisionMap[i].collisionFlags[x][y] = 0;
						}
					}
				}
			} else if (command.equals("pack")) {
				if (args[1].equalsIgnoreCase("model") && args.length == 3) {
					try {
						int modelIndex = Integer.parseInt(args[2]);
						byte[] data = getModel(modelIndex, args[3]);
						if ((data != null) && (data.length > 0)) {
							cacheIndices[1].store(data.length, data, modelIndex);
							printConsoleMessage("Packed model" + modelIndex + ".", 1);
						} else {
							printConsoleMessage("Model not found.", 1);
						}
					} catch (Exception e) {
						printConsoleMessage("Syntax: \"pack model <id> <path>\".", 1);
					}
				} else {
					printConsoleMessage("Syntax: \"pack model <id> <path>\".", 1);
				}
				if (args[1].equalsIgnoreCase("models") && args.length == 3) {
					try {
						for (int index = 0; index < 99999; index++) {
							byte[] data = getModel(index, args[3]);
							if ((data != null) && (data.length > 0)) {
								cacheIndices[1].store(data.length, data, index);
								printConsoleMessage("Model " + index + " has been packed.", 1);
							} else {
								printConsoleMessage("Couldn't find any models.", 0);
							}
						}
					} catch (Exception e) {
						printConsoleMessage("Syntax: \"pack models\".", 1);
					}
				} else {
					printConsoleMessage("Syntax: \"pack models <path>\".", 1);
				}
			} else if (command.equals("iteminfo")) {
				ItemWriter.dumpItems();
			} else if (command.equals("562")) {
				VERSION = 562;
				drawInventoryRequest = true;
				Client.inputTaken = true;
				drawMinimap();
				printConsoleMessage("Switching to 562 gameframe.", 1);
			} else if (command.equals("508")) {
				VERSION = 508;
				drawInventoryRequest = true;
				Client.inputTaken = true;
				drawMinimap();
				printConsoleMessage("Switching to 508 gameframe.", 1);
			} else if (command.equals("484")) {
				VERSION = 484;
				drawInventoryRequest = true;
				Client.inputTaken = true;
				drawMinimap();
				printConsoleMessage("Switching to 484 gameframe.", 1);
			} else if (command.equals("474")) {
				VERSION = 474;
				drawInventoryRequest = true;
				Client.inputTaken = true;
				drawMinimap();
				printConsoleMessage("Switching to 474 gameframe.", 1);
			} else {
				printConsoleMessage("Unknown developer command: " + input, 0);
			}
		} catch (Exception e) {
			return;
		}
	}

	private void drawFlames() {
		drawingFlames = true;
		try {
			long l = System.currentTimeMillis();
			int i = 0;
			int j = 20;
			while (flameRequest) {
				anInt1208++;
				calcFlamesPosition();
				calcFlamesPosition();
				doFlamesDrawing();
				if (++i > 10) {
					long l1 = System.currentTimeMillis();
					int k = (int) (l1 - l) / 10 - j;
					j = 40 - k;
					if (j < 5) {
						j = 5;
					}
					i = 0;
					l = l1;
				}
				try {
					Thread.sleep(j);
				} catch (Exception _ex) {
				}
			}
		} catch (Exception _ex) {
		}
		drawingFlames = false;
	}

	private void drawFriendsListOrWelcomeScreen(Interface interfaceInstance) {
		int j = interfaceInstance.contentType;
		if (((j >= 1) && (j <= 100)) || ((j >= 701) && (j <= 800))) {
			if ((j == 1) && (anInt900 == 0)) {
				interfaceInstance.message = "Loading friend list";
				interfaceInstance.atActionType = 0;
				return;
			}
			if ((j == 1) && (anInt900 == 1)) {
				interfaceInstance.message = "Connecting to friendserver";
				interfaceInstance.atActionType = 0;
				return;
			}
			if ((j == 2) && (anInt900 != 2)) {
				interfaceInstance.message = "Please wait...";
				interfaceInstance.atActionType = 0;
				return;
			}
			int k = friendsCount;
			if (anInt900 != 2) {
				k = 0;
			}
			if (j > 700) {
				j -= 601;
			} else {
				j--;
			}
			if (j >= k) {
				interfaceInstance.message = "";
				interfaceInstance.atActionType = 0;
				return;
			} else {
				interfaceInstance.message = friendsList[j];
				interfaceInstance.atActionType = 1;
				return;
			}
		}
		if (((j >= 101) && (j <= 200)) || ((j >= 801) && (j <= 900))) {
			int l = friendsCount;
			if (anInt900 != 2) {
				l = 0;
			}
			if (j > 800) {
				j -= 701;
			} else {
				j -= 101;
			}
			if (j >= l) {
				interfaceInstance.message = "";
				interfaceInstance.atActionType = 0;
				return;
			}
			if (friendsNodeIDs[j] == 0) {
				interfaceInstance.message = "@red@Offline";
			} else if (friendsNodeIDs[j] == Client.nodeID) {
				interfaceInstance.message = "@gre@Online";
			} else {
				interfaceInstance.message = "@red@Offline";
			}
			interfaceInstance.atActionType = 1;
			return;
		}
		if (j == 203) {
			int i1 = friendsCount;
			if (anInt900 != 2) {
				i1 = 0;
			}
			interfaceInstance.scrollMax = i1 * 15 + 20;
			if (interfaceInstance.scrollMax <= interfaceInstance.height) {
				interfaceInstance.scrollMax = interfaceInstance.height + 1;
			}
			return;
		}
		if ((j >= 401) && (j <= 500)) {
			if (((j -= 401) == 0) && (anInt900 == 0)) {
				interfaceInstance.message = "Loading ignore list";
				interfaceInstance.atActionType = 0;
				return;
			}
			if ((j == 1) && (anInt900 == 0)) {
				interfaceInstance.message = "Please wait...";
				interfaceInstance.atActionType = 0;
				return;
			}
			int j1 = ignoreCount;
			if (anInt900 == 0) {
				j1 = 0;
			}
			if (j >= j1) {
				interfaceInstance.message = "";
				interfaceInstance.atActionType = 0;
				return;
			} else {
				interfaceInstance.message = TextUtil
				.fixName(TextUtil.nameForLong(ignoreListAsLongs[j]));
				interfaceInstance.atActionType = 1;
				return;
			}
		}
		if (j == 503) {
			interfaceInstance.scrollMax = ignoreCount * 15 + 20;
			if (interfaceInstance.scrollMax <= interfaceInstance.height) {
				interfaceInstance.scrollMax = interfaceInstance.height + 1;
			}
			return;
		}
		if (j == 327) {
			interfaceInstance.modelRotation1 = 150;
			interfaceInstance.modelRotation2 = (int) (Math.sin(Client.loopCycle / 40D) * 256D) & 0x7ff;
			if (aBoolean1031) {
				for (int k1 = 0; k1 < 7; k1++) {
					int l1 = anIntArray1065[k1];
					if ((l1 >= 0) && !IdentityKit.cache[l1].method537()) {
						return;
					}
				}
				aBoolean1031 = false;
				Model models[] = new Model[7];
				int i2 = 0;
				for (int j2 = 0; j2 < 7; j2++) {
					int k2 = anIntArray1065[j2];
					if (k2 >= 0) {
						models[i2++] = IdentityKit.cache[k2].method538();
					}
				}
				Model model = new Model(i2, models);
				for (int l2 = 0; l2 < 5; l2++) {
					if (anIntArray990[l2] != 0) {
						model.method476(Client.anIntArrayArray1003[l2][0],
						Client.anIntArrayArray1003[l2][anIntArray990[l2]]);
						if (l2 == 1) {
							model.method476(Client.anIntArray1204[0],
							Client.anIntArray1204[anIntArray990[l2]]);
						}
					}
				}
				model.method469();
				model
				.method470(Animation.animations[Client.myPlayer.idleAnimation].anIntArray353[0]);
				model.preProcess(64, 850, -30, -50, -30, true);
				interfaceInstance.anInt233 = 5;
				interfaceInstance.mediaID = 0;
				Interface.method208(aBoolean994, model);
			}
			return;
		}
		if (j == 328) {
			Interface iComponent = interfaceInstance;
			int verticleTilt = 150;
			int animationSpeed = (int) (Math.sin(Client.loopCycle / 40D) * 256D) & 0x7ff;
			iComponent.modelRotation1 = verticleTilt;
			iComponent.modelRotation2 = animationSpeed;
			if (aBoolean1031) {
				Model characterDisplay = Client.myPlayer.method452();
				for (int l2 = 0; l2 < 5; l2++) {
					if (anIntArray990[l2] != 0) {
						characterDisplay.method476(Client.anIntArrayArray1003[l2][0],
						Client.anIntArrayArray1003[l2][anIntArray990[l2]]);
						if (l2 == 1) {
							characterDisplay.method476(Client.anIntArray1204[0],
							Client.anIntArray1204[anIntArray990[l2]]);
						}
					}
				}
				int staticFrame = Client.myPlayer.idleAnimation;
				characterDisplay.method469();
				characterDisplay.method470(Animation.animations[staticFrame].anIntArray353[0]);
				// characterDisplay.method479(64, 850, -30, -50, -30, true);
				iComponent.anInt233 = 5;
				iComponent.mediaID = 0;
				Interface.method208(aBoolean994, characterDisplay);
			}
			return;
		}
		if (j == 324) {
			if (aClass30_Sub2_Sub1_Sub1_931 == null) {
				aClass30_Sub2_Sub1_Sub1_931 = interfaceInstance.sprite1;
				aClass30_Sub2_Sub1_Sub1_932 = interfaceInstance.sprite2;
			}
			if (aBoolean1047) {
				interfaceInstance.sprite1 = aClass30_Sub2_Sub1_Sub1_932;
				return;
			} else {
				interfaceInstance.sprite1 = aClass30_Sub2_Sub1_Sub1_931;
				return;
			}
		}
		if (j == 325) {
			if (aClass30_Sub2_Sub1_Sub1_931 == null) {
				aClass30_Sub2_Sub1_Sub1_931 = interfaceInstance.sprite1;
				aClass30_Sub2_Sub1_Sub1_932 = interfaceInstance.sprite2;
			}
			if (aBoolean1047) {
				interfaceInstance.sprite1 = aClass30_Sub2_Sub1_Sub1_931;
				return;
			} else {
				interfaceInstance.sprite1 = aClass30_Sub2_Sub1_Sub1_932;
				return;
			}
		}
		if (j == 600) {
			interfaceInstance.message = reportAbuseInput;
			if (Client.loopCycle % 20 < 10) {
				interfaceInstance.message += "|";
				return;
			} else {
				interfaceInstance.message += " ";
				return;
			}
		}
		if (j == 613) {
			if (myPrivilege >= 1) {
				if (canMute) {
					interfaceInstance.textColor = 0xff0000;
					interfaceInstance.message = "Moderator option: Mute player for 48 hours: <ON>";
				} else {
					interfaceInstance.textColor = 0xffffff;
					interfaceInstance.message = "Moderator option: Mute player for 48 hours: <OFF>";
				}
			} else {
				interfaceInstance.message = "";
			}
		}
		if ((j == 650) || (j == 655)) {
			if (anInt1193 != 0) {
				String s;
				if (daysSinceLastLogin == 0) {
					s = "earlier today";
				} else if (daysSinceLastLogin == 1) {
					s = "yesterday";
				} else {
					s = daysSinceLastLogin + " days ago";
				}
				interfaceInstance.message = "You last logged in " + s + " from: " + Signlink.dns;
			} else {
				interfaceInstance.message = "";
			}
		}
		if (j == 651) {
			if (unreadMessages == 0) {
				interfaceInstance.message = "0 unread messages";
				interfaceInstance.textColor = 0xffff00;
			}
			if (unreadMessages == 1) {
				interfaceInstance.message = "1 unread message";
				interfaceInstance.textColor = 0x00ff00;
			}
			if (unreadMessages > 1) {
				interfaceInstance.message = unreadMessages + " unread messages";
				interfaceInstance.textColor = 0x00ff00;
			}
		}
		if (j == 652) {
			if (recoveriesLastSet == 201) {
				if (membersInt == 1) {
					interfaceInstance.message = "@yel@This is a non-members world: @whi@Since you are a member we";
				} else {
					interfaceInstance.message = "";
				}
			} else if (recoveriesLastSet == 200) {
				interfaceInstance.message = "You have not yet set any password recovery questions.";
			} else {
				String s1;
				if (recoveriesLastSet == 0) {
					s1 = "Earlier today";
				} else if (recoveriesLastSet == 1) {
					s1 = "Yesterday";
				} else {
					s1 = recoveriesLastSet + " days ago";
				}
				interfaceInstance.message = s1 + " you changed your recovery questions";
			}
		}
		if (j == 653) {
			if (recoveriesLastSet == 201) {
				if (membersInt == 1) {
					interfaceInstance.message = "@whi@recommend you use a members world instead. You may use";
				} else {
					interfaceInstance.message = "";
				}
			} else if (recoveriesLastSet == 200) {
				interfaceInstance.message = "We strongly recommend you do so now to secure your account.";
			} else {
				interfaceInstance.message = "If you do not remember making this change then cancel it immediately";
			}
		}
		if (j == 654) {
			if (recoveriesLastSet == 201) {
				if (membersInt == 1) {
					interfaceInstance.message = "@whi@this world but member benefits are unavailable whilst here.";
					return;
				} else {
					interfaceInstance.message = "";
					return;
				}
			}
			if (recoveriesLastSet == 200) {
				interfaceInstance.message = "Do this from the 'account management' area on our front webpage";
				return;
			}
			interfaceInstance.message = "Do this from the 'account management' area on our front webpage";
		}
	}

	private void drawGameScreen() {
		if ((fullscreenInterfaceID != -1)
		&& ((loadingStage == 2) || (super.fullGameScreen != null))) {
			if (loadingStage == 2) {
				method119(anInt945, fullscreenInterfaceID);
				if (openInterfaceID != -1) {
					method119(anInt945, openInterfaceID);
				}
				anInt945 = 0;
				resetAllGraphicsBuffers();
				super.fullGameScreen.init();
				Renderer3D.lineOffsets = fullScreenTexturePool;
				Renderer2D.clearPixels();
				welcomeScreenRaised = true;
				if (openInterfaceID != -1) {
					Interface iComponent = Interface.interfaceCache[openInterfaceID];
					if ((iComponent.width == 512) && (iComponent.height == 334)
					&& (iComponent.type == 0)) {
						iComponent.width = 765;
						iComponent.height = 503;
					}
					drawInterface(0, 0, iComponent, 8);
				}
				Interface iComponent = Interface.interfaceCache[fullscreenInterfaceID];
				if ((iComponent.width == 512) && (iComponent.height == 334)
				&& (iComponent.type == 0)) {
					iComponent.width = 765;
					iComponent.height = 503;
				}
				drawInterface(0, 0, iComponent, 8);
				if (!menuOpen) {
					processRightClick();
					drawTooltip();
				} else {
					drawMenu(4, 0);
				}
			}
			drawCount++;
			super.fullGameScreen.drawGraphics(super.graphics, 0, 0);
			return;
		} else {
			if (drawCount != 0) {
				resetGameScreenGraphicsBuffers();
			}
		}
		if (welcomeScreenRaised) {
			welcomeScreenRaised = false;
			topFrame.drawGraphics(super.graphics, 0, 0);
			leftFrame.drawGraphics(super.graphics, 0, 4);
			drawInventoryRequest = true;
			Client.inputTaken = true;
			inventoryAltered = true;
			if (loadingStage != 2) {
				gameScreenCanvas.drawGraphics(super.graphics, 4, 4);
				minimapCanvas.drawGraphics(super.graphics, 516, 0);
			}
		}
		if (menuOpen) {
			drawInventoryRequest = true;
		}
		if (invOverlayInterfaceID != -1) {
			boolean flag1 = method119(anInt945, invOverlayInterfaceID);
			if (flag1) {
				drawInventoryRequest = true;
			}
		}
		if (atInventoryInterfaceType == 2) {
			drawInventoryRequest = true;
		}
		if (activeInterfaceType == 2) {
			drawInventoryRequest = true;
		}
		if (drawInventoryRequest) {
			drawInventory();
			drawInventoryRequest = false;
		}
		if (backDialogID == -1) {
			iComponent.scrollPosition = scrollerHeight - Client.scrollerPosition - 110;
			if ((super.mouseX > 478) && (super.mouseX < 580) && (super.mouseY > 342)) {
				method65(494, 110, super.mouseX - 0, super.mouseY - 348, iComponent, 0, false,
				scrollerHeight);
			}
			int i = scrollerHeight - 110 - iComponent.scrollPosition;
			if (i < 0) {
				i = 0;
			}
			if (i > scrollerHeight - 110) {
				i = scrollerHeight - 110;
			}
			if (Client.scrollerPosition != i) {
				Client.scrollerPosition = i;
				Client.inputTaken = true;
			}
		}
		if (backDialogID != -1) {
			boolean flag2 = method119(anInt945, backDialogID);
			if (flag2) {
				Client.inputTaken = true;
			}
		}
		if (atInventoryInterfaceType == 3) {
			Client.inputTaken = true;
		}
		if (activeInterfaceType == 3) {
			Client.inputTaken = true;
		}
		if (continueMessageTitle != null) {
			Client.inputTaken = true;
		}
		if (menuOpen) {
			Client.inputTaken = true;
		}
		if (Client.inputTaken) {
			drawChatbox();
			drawConsole();
			Client.inputTaken = false;
		}
		if (loadingStage == 2) {
			method146();
		}
		if (loadingStage == 2) {
			drawMinimap();
			minimapCanvas.drawGraphics(super.graphics, 516, 0);
		}
		if (anInt1054 != -1) {
			inventoryAltered = true;
		}
		if (inventoryAltered) {
			if ((anInt1054 != -1) && (anInt1054 == tabID)) {
				anInt1054 = -1;
				outputStream.putOperation(120);
				outputStream.putByte(tabID);
			}
			inventoryAltered = false;
			gameScreenCanvas.init();
		}
		anInt945 = 0;
	}

	private void drawHeadIcon() {
		if (anInt855 != 2) {
			return;
		}
		getEntityScreenPos((anInt934 - baseX << 7) + anInt937, anInt936 * 2,
		(anInt935 - baseY << 7) + anInt938);
		if ((spriteDrawX > -1) && (Client.loopCycle % 20 < 10)) {
			headIcons_hint[0].drawSprite(spriteDrawX - 12, spriteDrawY - 28);
		}
	}

	private void drawInterface(int j, int k, Interface interfaceDrawn, int l) {
		if ((interfaceDrawn.type != 0) || (interfaceDrawn.children == null)) {
			return;
		}
		if (interfaceDrawn.hoverable && (anInt1026 != interfaceDrawn.id)
		&& (anInt1048 != interfaceDrawn.id) && (anInt1039 != interfaceDrawn.id)) {
			return;
		}
		int i1 = Renderer2D.topX;
		int j1 = Renderer2D.topY;
		int k1 = Renderer2D.bottomX;
		int l1 = Renderer2D.bottomY;
		Renderer2D.setDrawingArea(k, l, k + interfaceDrawn.width, l + interfaceDrawn.height);
		int i2 = interfaceDrawn.children.length;
		for (int j2 = 0; j2 < i2; j2++) {
			int k2 = interfaceDrawn.childX[j2] + k;
			int l2 = (interfaceDrawn.childY[j2] + l) - j;
			Interface iComponent = Interface.interfaceCache[interfaceDrawn.children[j2]];
			k2 += iComponent.anInt263;
			l2 += iComponent.anInt265;
			if (iComponent.contentType > 0) {
				drawFriendsListOrWelcomeScreen(iComponent);
			}
			if (iComponent.type == 0) {
				if (iComponent.scrollPosition > iComponent.scrollMax - iComponent.height) {
					iComponent.scrollPosition = iComponent.scrollMax - iComponent.height;
				}
				if (iComponent.scrollPosition < 0) {
					iComponent.scrollPosition = 0;
				}
				drawInterface(iComponent.scrollPosition, k2, iComponent, l2);
				if (iComponent.scrollMax > iComponent.height) {
					drawScrollBar(k2 + iComponent.width, l2, iComponent.scrollPosition,
					iComponent.scrollMax, iComponent.height);
				}
			} else if (iComponent.type != 1) {
				if (iComponent.type == 2) {
					int i3 = 0;
					for (int l3 = 0; l3 < iComponent.height; l3++) {
						for (int l4 = 0; l4 < iComponent.width; l4++) {
							int k5 = k2 + l4 * (32 + iComponent.invSpritePadX);
							int j6 = l2 + l3 * (32 + iComponent.invSpritePadY);
							if (i3 < 20) {
								k5 += iComponent.spritesX[i3];
								j6 += iComponent.spritesY[i3];
							}
							if (iComponent.inv[i3] > 0) {
								int k6 = 0;
								int j7 = 0;
								int j9 = iComponent.inv[i3] - 1;
								if (((k5 > Renderer2D.topX - 32) && (k5 < Renderer2D.bottomX)
								&& (j6 > Renderer2D.topY - 32) && (j6 < Renderer2D.bottomY))
								|| ((activeInterfaceType != 0) && (anInt1085 == i3))) {
									int l9 = 0;
									if ((itemSelected == 1) && (anInt1283 == i3)
									&& (anInt1284 == iComponent.id)) {
										l9 = 0xffffff;
									}
									Sprite sprite = ItemDefinition.getSprite(j9,
									iComponent.invStackSizes[i3], l9);
									if (sprite != null) {
										if ((activeInterfaceType != 0) && (anInt1085 == i3)
										&& (anInt1084 == iComponent.id)) {
											k6 = super.mouseX - anInt1087;
											j7 = super.mouseY - anInt1088;
											if ((k6 < 5) && (k6 > -5)) {
												k6 = 0;
											}
											if ((j7 < 5) && (j7 > -5)) {
												j7 = 0;
											}
											if (anInt989 < 5) {
												k6 = 0;
												j7 = 0;
											}
											sprite.drawSprite(k5 + k6, j6 + j7, 128);
											if ((j6 + j7 < Renderer2D.topY)
											&& (interfaceDrawn.scrollPosition > 0)) {
												int i10 = (anInt945 * (Renderer2D.topY - j6 - j7)) / 3;
												if (i10 > anInt945 * 10) {
													i10 = anInt945 * 10;
												}
												if (i10 > interfaceDrawn.scrollPosition) {
													i10 = interfaceDrawn.scrollPosition;
												}
												interfaceDrawn.scrollPosition -= i10;
												anInt1088 += i10;
											}
											if ((j6 + j7 + 32 > Renderer2D.bottomY)
											&& (interfaceDrawn.scrollPosition < interfaceDrawn.scrollMax
											- interfaceDrawn.height)) {
												int j10 = (anInt945 * ((j6 + j7 + 32) - Renderer2D.bottomY)) / 3;
												if (j10 > anInt945 * 10) {
													j10 = anInt945 * 10;
												}
												if (j10 > interfaceDrawn.scrollMax
												- interfaceDrawn.height
												- interfaceDrawn.scrollPosition) {
													j10 = interfaceDrawn.scrollMax
													- interfaceDrawn.height
													- interfaceDrawn.scrollPosition;
												}
												interfaceDrawn.scrollPosition += j10;
												anInt1088 -= j10;
											}
										} else if ((atInventoryInterfaceType != 0)
										&& (atInventoryIndex == i3)
										&& (atInventoryInterface == iComponent.id)) {
											sprite.drawSprite(k5, j6, 128);
										} else {
											sprite.drawSprite(k5, j6);
										}
										if ((sprite.trimWidth == 33)
										|| (iComponent.invStackSizes[i3] != 1)) {
											int k10 = iComponent.invStackSizes[i3];
											smallText.drawText(Client.formatValue(k10),
											k5 + 1 + k6, j6 + 10 + j7, 0);
											smallText.drawText(Client.formatValue(k10), k5 + k6, j6
											+ 9 + j7, 0xffff00);
										}
									}
								}
							} else if ((iComponent.sprites != null) && (i3 < 20)) {
								Sprite sprite = iComponent.sprites[i3];
								if (sprite != null) {
									sprite.drawSprite(k5, j6);
								}
							}
							i3++;
						}
					}
				} else if (iComponent.type == 3) {
					boolean flag = false;
					if ((anInt1039 == iComponent.id) || (anInt1048 == iComponent.id)
					|| (anInt1026 == iComponent.id)) {
						flag = true;
					}
					int j3;
					if (interfaceIsSelected(iComponent)) {
						j3 = iComponent.anInt219;
						if (flag && (iComponent.anInt239 != 0)) {
							j3 = iComponent.anInt239;
						}
					} else {
						j3 = iComponent.textColor;
						if (flag && (iComponent.anInt216 != 0)) {
							j3 = iComponent.anInt216;
						}
					}
					if (iComponent.opacity == 0) {
						if (iComponent.aBoolean227) {
							Renderer2D.fillRectangle(k2, l2, iComponent.width, iComponent.height,
							j3);
						} else {
							Renderer2D.fillPixels(k2, iComponent.width, iComponent.height, j3, l2);
						}
					} else if (iComponent.aBoolean227) {
						Renderer2D.fillRectangle(k2, l2, iComponent.width, iComponent.height, j3,
						256 - (iComponent.opacity & 0xff));
					} else {
						Renderer2D.drawUnfilledBox(k2, l2, iComponent.width, iComponent.height, j3,
						256 - (iComponent.opacity & 0xff));
					}
				} else if (iComponent.type == 4) {
					Font rsFont = iComponent.font;
					String s = iComponent.message;
					boolean flag1 = false;
					if ((anInt1039 == iComponent.id) || (anInt1048 == iComponent.id)
					|| (anInt1026 == iComponent.id)) {
						flag1 = true;
					}
					int i4;
					if (interfaceIsSelected(iComponent)) {
						i4 = iComponent.anInt219;
						if (flag1 && (iComponent.anInt239 != 0)) {
							i4 = iComponent.anInt239;
						}
						if (iComponent.disabledMessage.length() > 0) {
							s = iComponent.disabledMessage;
						}
					} else {
						i4 = iComponent.textColor;
						if (flag1 && (iComponent.anInt216 != 0)) {
							i4 = iComponent.anInt216;
						}
					}
					if ((iComponent.atActionType == 6) && aBoolean1149) {
						s = "Please wait...";
						i4 = iComponent.textColor;
					}
					if (Renderer2D.width == 516) {
						if (i4 == 0xffff00) {
							i4 = 255;
						}
						if (i4 == 49152) {
							i4 = 0xffffff;
						}
					}
					for (int l6 = l2 + rsFont.offset; s.length() > 0; l6 += rsFont.offset) {
						if (s.indexOf("%") != -1) {
							do {
								int k7 = s.indexOf("%1");
								if (k7 == -1) {
									break;
								}
								s = s.substring(0, k7)
								+ interfaceIntToString(extractInterfaceValues(iComponent, 0))
								+ s.substring(k7 + 2);
							} while (true);
							do {
								int l7 = s.indexOf("%2");
								if (l7 == -1) {
									break;
								}
								s = s.substring(0, l7)
								+ interfaceIntToString(extractInterfaceValues(iComponent, 1))
								+ s.substring(l7 + 2);
							} while (true);
							do {
								int i8 = s.indexOf("%3");
								if (i8 == -1) {
									break;
								}
								s = s.substring(0, i8)
								+ interfaceIntToString(extractInterfaceValues(iComponent, 2))
								+ s.substring(i8 + 2);
							} while (true);
							do {
								int j8 = s.indexOf("%4");
								if (j8 == -1) {
									break;
								}
								s = s.substring(0, j8)
								+ interfaceIntToString(extractInterfaceValues(iComponent, 3))
								+ s.substring(j8 + 2);
							} while (true);
							do {
								int k8 = s.indexOf("%5");
								if (k8 == -1) {
									break;
								}
								s = s.substring(0, k8)
								+ interfaceIntToString(extractInterfaceValues(iComponent, 4))
								+ s.substring(k8 + 2);
							} while (true);
						}
						int l8 = s.indexOf("\\n");
						String s1;
						if (l8 != -1) {
							s1 = s.substring(0, l8);
							s = s.substring(l8 + 2);
						} else {
							s1 = s;
							s = "";
						}
						if (iComponent.centerText) {
							rsFont.drawCenteredText(s1, k2 + iComponent.width / 2, l6, i4,
							iComponent.textShadow);
						} else {
							rsFont.drawText(s1, k2, l6, i4, iComponent.textShadow);
						}
					}
				} else if (iComponent.type == 5) {
					Sprite sprite;
					if (interfaceIsSelected(iComponent)) {
						sprite = iComponent.sprite2;
					} else {
						sprite = iComponent.sprite1;
					}
					if (sprite != null) {
						if (iComponent.drawsTransparent == true) {
							sprite.drawSprite(k2, l2, 225);
						} else {
							sprite.drawSprite(k2, l2);
						}
					}
				} else if (iComponent.type == 6) {
					int k3 = Renderer3D.middleX;
					int j4 = Renderer3D.middleY;
					Renderer3D.middleX = k2 + iComponent.width / 2;
					Renderer3D.middleY = l2 + iComponent.height / 2;
					int i5 = Renderer3D.sineTable[iComponent.modelRotation1] * iComponent.modelZoom >> 16;
					int l5 = Renderer3D.cosineTable[iComponent.modelRotation1]
					* iComponent.modelZoom >> 16;
					boolean flag2 = interfaceIsSelected(iComponent);
					int i7;
					if (flag2) {
						i7 = iComponent.anInt258;
					} else {
						i7 = iComponent.anInt257;
					}
					Model model;
					if (i7 == -1) {
						model = iComponent.method209(-1, -1, flag2);
					} else {
						Animation animation = Animation.animations[i7];
						model = iComponent.method209(
						animation.anIntArray354[iComponent.anInt246],
						animation.anIntArray353[iComponent.anInt246], flag2);
					}
					if (model != null) {
						model.method482(iComponent.modelRotation2, 0,
						iComponent.modelRotation1, 0, i5, l5);
					}
					Renderer3D.middleX = k3;
					Renderer3D.middleY = j4;
				} else if (iComponent.type == 7) {
					Font textDrawingArea_1 = iComponent.font;
					int k4 = 0;
					for (int j5 = 0; j5 < iComponent.height; j5++) {
						for (int i6 = 0; i6 < iComponent.width; i6++) {
							if (iComponent.inv[k4] > 0) {
								ItemDefinition itemDefinition = ItemDefinition
								.forID(iComponent.inv[k4] - 1);
								String s2 = itemDefinition.name;
								if (itemDefinition.stackable || (iComponent.invStackSizes[k4] != 1)) {
									s2 = s2 + " x"
									+ Client.getFormattedValue(iComponent.invStackSizes[k4]);
								}
								int i9 = k2 + i6 * (115 + iComponent.invSpritePadX);
								int k9 = l2 + j5 * (12 + iComponent.invSpritePadY);
								if (iComponent.centerText) {
									textDrawingArea_1.drawCenteredText(s2, i9 + iComponent.width
									/ 2, k9, iComponent.textColor, iComponent.textShadow);
								} else {
									textDrawingArea_1.drawText(s2, i9, k9, iComponent.textColor,
									iComponent.textShadow);
								}
							}
							k4++;
						}
					}
				}
			}
		}
		Renderer2D.setDrawingArea(i1, j1, k1, l1);
	}

	@Override
	void drawLoadingText(int width, String text) {
		loadingTextWidth = width;
		loadingText = text;
		resetTitleScreenGraphicsBuffers();
		if (titleArchive == null) {
			super.drawLoadingText(width, text);
			return;
		}
		leftCanvas.init();
		boldText.drawCenteredText("RuneScape is loading - please wait...", 180, 54, 0xffffff);
		Renderer2D.fillPixels(28, 304, 34, 0x8c1111, 62);
		Renderer2D.fillPixels(29, 302, 32, 0, 63);
		Renderer2D.fillRectangle(30, 64, width * 3, 30, 0x8c1111);
		Renderer2D.fillRectangle(30 + width * 3, 64, 300 - width * 3, 30, 0);
		boldText.drawCenteredText(text, 180, 85, 0xffffff);
		leftCanvas.drawGraphics(super.graphics, 202, 171);
		if (welcomeScreenRaised) {
			welcomeScreenRaised = false;
			if (!flameRequest) {
				leftFlameCanvas.drawGraphics(super.graphics, 0, 0);
				rightFlameCanvas.drawGraphics(super.graphics, 637, 0);
			}
			topLeftCanvas.drawGraphics(super.graphics, 128, 0);
			bottomLeftCanvas.drawGraphics(super.graphics, 202, 371);
			titleBoxLeftCanvas.drawGraphics(super.graphics, 0, 265);
			bottomRightCanvas.drawGraphics(super.graphics, 562, 265);
			smallLeftCanvas.drawGraphics(super.graphics, 128, 171);
			smallRightCanvas.drawGraphics(super.graphics, 562, 171);
		}
	}

	/**
	 * Processes the actions on the login screen.
	 * 
	 * @param loggedIn
	 *            Is the character logged in?
	 */
	private void drawTitlebox(boolean loggedIn) {
		resetTitleScreenGraphicsBuffers();
		leftCanvas.init();
		titleBox.drawIndexedSprite(0, 0);
		if (loginScreenState == 0) { // Screen first loaded.
			smallText.drawCenteredText(onDemandFetcher.status, 180, 180, 0x75a9a9, true);
			boldText.drawCenteredText("Welcome to RuneScape", 180, 80, 0xffff00, true);
			titleButton.drawIndexedSprite(27, 100);
			boldText.drawCenteredText("New User", 100, 125, 0xffffff, true);
			titleButton.drawIndexedSprite(187, 100);
			boldText.drawCenteredText("Existing User", 260, 125, 0xffffff, true);
		}
		if (loginScreenState == 2) { // Existing user option.
			if (loginMessage1.length() > 0) {
				boldText.drawCenteredText(loginMessage1, 180, 45, 0xffff00, true);
				boldText.drawCenteredText(loginMessage2, 180, 60, 0xffff00, true);
			} else {
				boldText.drawCenteredText(loginMessage2, 180, 53, 0xffff00, true);
			}
			boldText.drawText("Username: " + myUsername
			+ ((loginScreenCursorPos == 0) & (Client.loopCycle % 40 < 20) ? "@yel@|" : ""), 90, 90,
			0xffffff, true);
			boldText.drawText("Password: " + TextUtil.passwordAsterisks(myPassword)
			+ ((loginScreenCursorPos == 1) & (Client.loopCycle % 40 < 20) ? "@yel@|" : ""), 92,
			105, 0xffffff, true);
			if (!loggedIn) {
				titleButton.drawIndexedSprite(27, 130);
				boldText.drawCenteredText("Login", 100, 155, 0xffffff, true);
				titleButton.drawIndexedSprite(187, 130);
				boldText.drawCenteredText("Cancel", 260, 155, 0xffffff, true);
			}
		}
		if (loginScreenState == 3) { // New user option.
			boldText.drawCenteredText("Create a free account", 180, 40, 0xffff00, true);
			boldText.drawCenteredText("To create a new account you need to", 180, 65, 0xffffff,
			true);
			boldText.drawCenteredText("go back to the main RuneScape webpage", 180, 80, 0xffffff,
			true);
			boldText.drawCenteredText("and choose the red 'create account'", 180, 95, 0xffffff,
			true);
			boldText.drawCenteredText("button at the top right of that page.", 180, 110, 0xffffff,
			true);
			titleButton.drawIndexedSprite(107, 130);
			boldText.drawCenteredText("Cancel", 180, 155, 0xffffff, true);
		}
		leftCanvas.drawGraphics(super.graphics, 202, 171);
		if (welcomeScreenRaised) {
			welcomeScreenRaised = false;
			topLeftCanvas.drawGraphics(super.graphics, 128, 0);
			bottomLeftCanvas.drawGraphics(super.graphics, 202, 371);
			titleBoxLeftCanvas.drawGraphics(super.graphics, 0, 265);
			bottomRightCanvas.drawGraphics(super.graphics, 562, 265);
			smallLeftCanvas.drawGraphics(super.graphics, 128, 171);
			smallRightCanvas.drawGraphics(super.graphics, 562, 171);
		}
	}

	private void drawTitleScreen() {
		Sprite sprite = new Sprite("background", 0);
		leftFlameCanvas.init();
		sprite.drawInverse(0, 0);
		topLeftCanvas.init();
		sprite.drawInverse(-128, 0);
		bottomLeftCanvas.init();
		sprite.drawInverse(-202, -371);
		leftCanvas.init();
		sprite.drawInverse(-202, -171);
		titleBoxLeftCanvas.init();
		sprite.drawInverse(0, -265);
		smallLeftCanvas.init();
		sprite.drawInverse(-128, -171);
		int ai[] = new int[sprite.width];
		for (int j = 0; j < sprite.height; j++) {
			for (int k = 0; k < sprite.width; k++) {
				ai[k] = sprite.pixels[(sprite.width - k - 1) + sprite.width * j];
			}
			System.arraycopy(ai, 0, sprite.pixels, sprite.width * j, sprite.width);
		}
		leftFlameCanvas.init();
		sprite.drawInverse(382, 0);
		rightFlameCanvas.init();
		sprite.drawInverse(-255, 0);
		topLeftCanvas.init();
		sprite.drawInverse(254, 0);
		bottomLeftCanvas.init();
		sprite.drawInverse(180, -371);
		leftCanvas.init();
		sprite.drawInverse(180, -171);
		titleBoxLeftCanvas.init();
		sprite.drawInverse(382, -265);
		bottomRightCanvas.init();
		sprite.drawInverse(-180, -265);
		smallLeftCanvas.init();
		sprite.drawInverse(254, -171);
		smallRightCanvas.init();
		sprite.drawInverse(-180, -171);
		sprite = null;
		System.gc();
	}

	private void drawMinimapIcons() {
		switch (VERSION) {
			case 508:
				worldMapGlobe[0].drawSprite(10, 124);
				break;
			case 562:
				worldMapGlobe[1 + worldMapHover].drawSprite(10, 124);
		}
		if ((tabInterfaceIDs[10] != -1) && (anInt1054 == 10)) {
			if (Client.loopCycle % 20 >= 10) {
				;
			}
		}
		switch (VERSION) {
			case 484:
				logoutDoor[0].drawSprite(226, 1);
				break;
			case 508:
				logoutDoor[2 + doorHover].drawSprite(226, 1);
				break;
			case 562:
				logoutDoor[5 + doorHover].drawSprite(228, 0);
				break;
		}
		if (tabID == 10) {
			switch (VERSION) {
				case 484:
					logoutDoor[1].drawSprite(226, 1);
					break;
				case 508:
					logoutDoor[4].drawSprite(226, 1);
					break;
				case 562:
					logoutDoor[7].drawSprite(228, 0);
					break;
			}
		}
	}

	private void drawMenu(int offsetX, int offsetY) {
		int x = menuOffsetX - (offsetX - 4);
		int y = (-offsetY) + menuOffsetY;
		int width = menuWidth;
		int height = menuHeight + 1;
		int color = 0x5d5447;
		drawInventoryRequest = true;
		Client.inputTaken = true;
		inventoryAltered = true;
		Renderer2D.fillRectangle(x, y, width, height, color);
		Renderer2D.fillRectangle(x + 1, y + 1, width - 2, 16, 0);
		Renderer2D.fillPixels(x + 1, width - 2, height - 19, 0, y + 18);
		boldText.drawText("Choose Option", x + 3, y + 14, color);
		int mouseX = super.mouseX - (offsetX);
		int mouseY = (-offsetY) + super.mouseY;
		for (int l1 = 0; l1 < menuActionRow; l1++) {
			int textY = y + 31 + (menuActionRow - 1 - l1) * 15;
			int disColor = 0xffffff;
			if ((mouseX > x) && (mouseX < x + width) && (mouseY > textY - 13)
			&& (mouseY < textY + 3)) {
				disColor = 0xffff00;
			}
			boldText.drawText(menuActionName[l1], x + 3, textY, disColor, true);
		}
	}

	private void drawMinimap() {
		minimapCanvas.init();
		if (anInt1021 == 2) {
			byte pixels[];
			pixels = roundMapBack.pixels;
			int reset[] = Renderer2D.pixels;
			for (int loop = 0; loop < pixels.length; loop++) {
				if (pixels[loop] == 0) {
					reset[loop] = 0;
				}
			}
			compass.drawShape(11, 8, 33, 33, compassTrimRight, compassTrimLeft,
			minimapAndCompassRotation, 256, 25, 25);
			gameScreenCanvas.init();
			return;
		}
		int i = minimapAndCompassRotation + minimapRotation & 0x7ff;
		int j = 48 + Client.myPlayer.x / 32;
		int l2 = 464 - Client.myPlayer.y / 32;
		if (VERSION > 474) {
			miniMap.drawShape(35, 8, 152, 153, miniMapTrimRight, miniMapTrimLeft, i,
			256 + minimapZoom, l2, j);
			compass.drawShape(11, 8, 33, 33, compassTrimRight, compassTrimLeft,
			minimapAndCompassRotation, 256, 25, 25);
		} else {
			miniMap.drawShape(52, 7, 152, 153, miniMapTrimRight, miniMapTrimLeft, i,
			256 + minimapZoom, l2, j);
			compass.drawShape(29, 4, 33, 33, compassTrimRight, compassTrimLeft,
			minimapAndCompassRotation, 256, 25, 25);
		}
		for (int j5 = 0; j5 < anInt1071; j5++) {
			int x = (anIntArray1072[j5] * 4 + 2) - Client.myPlayer.x / 32;
			int y = (anIntArray1073[j5] * 4 + 2) - Client.myPlayer.y / 32;
			markMinimap(aClass30_Sub2_Sub1_Sub1Array1140[j5], x, y);
		}
		for (int k5 = 0; k5 < 104; k5++) {
			for (int l5 = 0; l5 < 104; l5++) {
				Deque deque = groundArray[plane][k5][l5];
				if (deque != null) {
					int x = (k5 * 4 + 2) - Client.myPlayer.x / 32;
					int y = (l5 * 4 + 2) - Client.myPlayer.y / 32;
					markMinimap(mapDotItem, x, y);
				}
			}
		}
		for (int i6 = 0; i6 < npcCount; i6++) {
			Npc npc = npcArray[npcIndices[i6]];
			if ((npc != null) && npc.isVisible()) {
				EntityDefinition entityDefinition = npc.desc;
				if (entityDefinition.childrenIDs != null) {
					entityDefinition = entityDefinition.method161();
				}
				if ((entityDefinition != null) && entityDefinition.aBoolean87
				&& entityDefinition.aBoolean84) {
					int x = npc.x / 32 - Client.myPlayer.x / 32;
					int y = npc.y / 32 - Client.myPlayer.y / 32;
					markMinimap(mapDotNPC, x, y);
				}
			}
		}
		for (int j6 = 0; j6 < playerCount; j6++) {
			Player player = playerArray[playerIndices[j6]];
			if ((player != null) && player.isVisible()) {
				int x = player.x / 32 - Client.myPlayer.x / 32;
				int y = player.y / 32 - Client.myPlayer.y / 32;
				boolean flag1 = false;
				long l6 = TextUtil.longForName(player.name);
				for (int k6 = 0; k6 < friendsCount; k6++) {
					if ((l6 != friendsListAsLongs[k6]) || (friendsNodeIDs[k6] == 0)) {
						continue;
					}
					flag1 = true;
					break;
				}
				boolean flag2 = false;
				if ((Client.myPlayer.team != 0) && (player.team != 0)
				&& (Client.myPlayer.team == player.team)) {
					flag2 = true;
				}
				if (flag1) {
					markMinimap(mapDotFriend, x, y);
				} else if (flag2) {
					markMinimap(mapDotTeam, x, y);
				} else {
					markMinimap(mapDotPlayer, x, y);
				}
			}
		}
		if ((anInt855 != 0) && (Client.loopCycle % 20 < 10)) {
			if ((anInt855 == 1) && (anInt1222 >= 0) && (anInt1222 < npcArray.length)) {
				Npc npc = npcArray[anInt1222];
				if (npc != null) {
					int x = npc.x / 32 - Client.myPlayer.x / 32;
					int y = npc.y / 32 - Client.myPlayer.y / 32;
					method81(mapMarker, y, x);
				}
			}
			if (anInt855 == 2) {
				int x = ((anInt934 - baseX) * 4 + 2) - Client.myPlayer.x / 32;
				int y = ((anInt935 - baseY) * 4 + 2) - Client.myPlayer.y / 32;
				method81(mapMarker, y, x);
			}
			if ((anInt855 == 10) && (anInt933 >= 0) && (anInt933 < playerArray.length)) {
				Player player = playerArray[anInt933];
				if (player != null) {
					int x = player.x / 32 - Client.myPlayer.x / 32;
					int y = player.y / 32 - Client.myPlayer.y / 32;
					method81(mapMarker, y, x);
				}
			}
		}
		if (destX != 0) {
			int j2 = (destX * 4 + 2) - Client.myPlayer.x / 32;
			int l4 = (destY * 4 + 2) - Client.myPlayer.y / 32;
			markMinimap(mapFlag, j2, l4);
		}
		mapBackground[getImageId()].drawSprite(0, 0);
		if (VERSION > 474) {
			drawMinimapIcons();
			drawStatusGlobes();
			Renderer2D.fillRectangle(110, 84, 3, 3, 0xffffff);
		} else {
			Renderer2D.fillRectangle(126, 82, 3, 3, 0xffffff);
		}
		if (menuOpen) {
			drawMenu(516, -4);
		}
		gameScreenCanvas.init();
	}

	public void drawRedStones() {
		if (tabInterfaceIDs[tabID] != -1) {
			if (VERSION > 508) {
				switch (tabID) {
					case 0:
					case 1:
					case 2:
						redStones[5].drawAlphaSprite((30 * tabID) - 1, 0);
						break;
					case 3:
					case 4:
					case 5:
					case 6:
						redStones[5].drawAlphaSprite((30 * tabID) + 29, 0);
						break;
					case 15:
						redStones[5].drawSprite(89, 0);
						break;
					case 7:
						redStones[5].drawAlphaSprite(89, 298);
						break;
					case 8:
					case 9:
					case 11:
					case 12:
					case 13:
						redStones[5].drawAlphaSprite((30 * (tabID - 7)) - 1, 298);
						break;
				}
			} else {
				switch (tabID) {
					case 0:
						redStones[0].drawSprite(6, 0);
						break;
					case 1:
						redStones[4].drawSprite(44, 0);
						break;
					case 2:
						redStones[4].drawSprite(77, 0);
						break;
					case 3:
						redStones[4].drawSprite(110, 0);
						break;
					case 4:
						redStones[4].drawSprite(143, 0);
						break;
					case 5:
						redStones[4].drawSprite(176, 0);
						break;
					case 6:
						redStones[1].drawSprite(209, 0);
						break;
					case 7:
						redStones[2].drawSprite(6, 298);
						break;
					case 8:
						redStones[4].drawSprite(44, 298);
						break;
					case 9:
						redStones[4].drawSprite(77, 298);
						break;
					case 10:
						if (VERSION < 484) {
							redStones[4].drawSprite(110, 298);
						}
						break;
					case 14:
						redStones[4].drawSprite(110, 298);
						break;
					case 11:
						redStones[4].drawSprite(143, 298);
						break;
					case 12:
						redStones[4].drawSprite(176, 298);
						break;
					case 13:
						redStones[3].drawSprite(209, 298);
						break;
				}
			}
		}
	}

	/**
	 * Draws the scrollbar used in interfaces.
	 * 
	 * @param x
	 *            The x position of the entire scrollbar.
	 * @param y
	 *            The y position of the entire scrollbar.
	 * @param scrollPosition
	 *            The position of the middle section.
	 * @param scrollHeight
	 *            The height of the middle section.
	 * @param fullHeight
	 *            The height of the entire scrollbar.
	 */
	private void drawScrollBar(int x, int y, int scrollPosition, int scrollHeight, int fullHeight) {
		int backingAmount = (fullHeight - 32) / 5;
		int scrollPartHeight = ((fullHeight - 32) * fullHeight) / scrollHeight;
		if (scrollPartHeight < 8) {
			scrollPartHeight = 8;
		}
		int scrollPartAmount = (scrollPartHeight / 5) - 2;
		int middlePosition = ((fullHeight - 32 - scrollPartHeight) * scrollPosition)
		/ (scrollHeight - fullHeight) + 16 + y;
		if (VERSION > 484) {
			/**
			 * Draws the background.
			 */
			for (int i = 0, yPosition = y + 16; i <= backingAmount; i++, yPosition += 5) {
				scrollBar[17].drawSprite(x, yPosition);
			}
			/**
			 * Draws the top.
			 */
			scrollBar[14].drawSprite(x, middlePosition);
			middlePosition += 5;
			/**
			 * Draws the middle.
			 */
			for (int i = 0; i <= scrollPartAmount; i++) {
				scrollBar[15].drawSprite(x, middlePosition);
				middlePosition += 5;
			}
			/**
			 * Draws the bottom.
			 */
			middlePosition = ((fullHeight - 32 - scrollPartHeight) * scrollPosition)
			/ (scrollHeight - fullHeight) + 16 + y + (scrollPartHeight - 5);
			scrollBar[16].drawSprite(x, middlePosition);
			/**
			 * Draws the buttons.
			 */
			scrollBar[12].drawSprite(x, y);
			scrollBar[13].drawSprite(x, (y + fullHeight) - 16);
		} else {
			/**
			 * Draws the background.
			 */
			for (int i = 0, yPosition = y + 16; i <= backingAmount; i++, yPosition += 5) {
				scrollBar[5].drawSprite(x, yPosition);
			}
			/**
			 * Draws the top.
			 */
			scrollBar[2].drawSprite(x, middlePosition);
			middlePosition += 5;
			/**
			 * Draws the middle.
			 */
			for (int i = 0; i <= scrollPartAmount; i++) {
				scrollBar[3].drawSprite(x, middlePosition);
				middlePosition += 5;
			}
			/**
			 * Draws the bottom.
			 */
			middlePosition = ((fullHeight - 32 - scrollPartHeight) * scrollPosition)
			/ (scrollHeight - fullHeight) + 16 + y + (scrollPartHeight - 5);
			scrollBar[4].drawSprite(x, middlePosition);
			/**
			 * Draws the buttons.
			 */
			scrollBar[0].drawSprite(x, y);
			scrollBar[1].drawSprite(x, (y + fullHeight) - 16);
		}
	}

	public void drawSideIcons() {
		if (VERSION > 508) {
			if (tabInterfaceIDs[0] != -1) {
				sideIcons[15].drawSprite(11, 9);
			}
			if (tabInterfaceIDs[1] != -1) {
				sideIcons[16].drawSprite(40, 9);
			}
			if (tabInterfaceIDs[2] != -1) {
				sideIcons[17].drawSprite(70, 8);
			}
			// if (tabInterfaceIDs[16] != -1)
			sideIcons[18].drawSprite(100, 8);
			if (tabInterfaceIDs[3] != -1) {
				sideIcons[19].drawSprite(130, 9);
			}
			if (tabInterfaceIDs[4] != -1) {
				sideIcons[20].drawSprite(162, 8);
			}
			if (tabInterfaceIDs[5] != -1) {
				sideIcons[21].drawSprite(190, 8);
			}
			if (tabInterfaceIDs[6] != -1) {
				sideIcons[22].drawSprite(220, 9);
			}
			if (tabInterfaceIDs[8] != -1) {
				sideIcons[23].drawSprite(41, 307);
			}
			if (tabInterfaceIDs[9] != -1) {
				sideIcons[24].drawSprite(73, 307);
			}
			// if (tabInterfaceIDs[7] != -1)
			sideIcons[25].drawSprite(100, 308);
			if (tabInterfaceIDs[11] != -1) {
				sideIcons[26].drawSprite(130, 307);
			}
			if (tabInterfaceIDs[12] != -1) {
				sideIcons[27].drawSprite(160, 307);
			}
			if (tabInterfaceIDs[13] != -1) {
				sideIcons[28].drawSprite(189, 306);
			}
			if (tabInterfaceIDs[16] != -1) {
				sideIcons[29].drawSprite(220, 309);
			}
		} else {
			if (tabInterfaceIDs[0] != -1) {
				sideIcons[0].drawSprite(17, 9);
			}
			if (tabInterfaceIDs[1] != -1) {
				sideIcons[1].drawSprite(49, 7);
			}
			if (tabInterfaceIDs[2] != -1) {
				sideIcons[2].drawSprite(83, 7);
			}
			if (tabInterfaceIDs[3] != -1) {
				sideIcons[3].drawSprite(114, 5);
			}
			if (tabInterfaceIDs[4] != -1) {
				sideIcons[4].drawSprite(146, 2);
			}
			if (tabInterfaceIDs[5] != -1) {
				sideIcons[5].drawSprite(180, 3);
			}
			if (tabInterfaceIDs[6] != -1) {
				sideIcons[6].drawSprite(214, 7);
			}
			if (tabInterfaceIDs[14] != -1) {
				sideIcons[14].drawSprite(13, 302);
			}
			if (tabInterfaceIDs[8] != -1) {
				sideIcons[8].drawSprite(49, 306);
			}
			if (tabInterfaceIDs[9] != -1) {
				sideIcons[9].drawSprite(82, 306);
			}
			// if (tabInterfaceIDs[7] != -1)// Clan Chat
			if (VERSION > 474) {
				sideIcons[7].drawSprite(115, 304);
			} else {
				sideIcons[7].drawSprite(14, 303);
				if (tabInterfaceIDs[10] != -1) {
					sideIcons[10].drawSprite(116, 302);
				}
			}
			if (tabInterfaceIDs[11] != -1) {
				sideIcons[11].drawSprite(148, 304);
			}
			if (tabInterfaceIDs[12] != -1) {
				sideIcons[12].drawSprite(184, 302);
			}
			if (tabInterfaceIDs[13] != -1) {
				sideIcons[13].drawSprite(216, 303);
			}
		}
	}

	private void drawSplitPrivateChat() {
		if (splitPrivateChat == 0) {
			return;
		}
		Font font = plainText;
		int i = 0;
		if (anInt1104 != 0) {
			i = 1;
		}
		for (int j = 0; j < 100; j++) {
			if (chatMessages[j] != null) {
				int k = chatTypes[j];
				String s = chatNames[j];
				byte byte1 = 0;
				if ((s != null) && s.startsWith("@cr1@")) {
					s = s.substring(5);
					byte1 = 1;
				}
				if ((s != null) && s.startsWith("@cr2@")) {
					s = s.substring(5);
					byte1 = 2;
				}
				if (((k == 3) || (k == 7))
				&& ((k == 7) || (privateChatMode == 0) || ((privateChatMode == 1) && isFriendOrSelf(s)))) {
					int l = 329 - i * 13;
					int k1 = 4;
					font.drawText("From", k1, l, 0);
					font.drawText("From", k1, l - 1, 65535);
					k1 += font.getTextWidth("From ");
					if (byte1 == 1) {
						modIcons[0].drawIndexedSprite(k1, l - 12);
						k1 += 12;
					}
					if (byte1 == 2) {
						modIcons[1].drawIndexedSprite(k1, l - 12);
						k1 += 12;
					}
					font.drawText(s + ": " + chatMessages[j], k1, l, 0);
					font.drawText(s + ": " + chatMessages[j], k1, l - 1, 65535);
					if (++i >= 5) {
						return;
					}
				}
				if ((k == 5) && (privateChatMode < 2)) {
					int i1 = 329 - i * 13;
					font.drawText(chatMessages[j], 4, i1, 0);
					font.drawText(chatMessages[j], 4, i1 - 1, 65535);
					if (++i >= 5) {
						return;
					}
				}
				if ((k == 6) && (privateChatMode < 2)) {
					int j1 = 329 - i * 13;
					font.drawText("To " + s + ": " + chatMessages[j], 4, j1, 0);
					font.drawText("To " + s + ": " + chatMessages[j], 4, j1 - 1, 65535);
					if (++i >= 5) {
						return;
					}
				}
			}
		}
	}

	private void drawStatusGlobes() {
		// Hit-points globe. 
		int hpPercent = 100 * currentStats[3] / maxStats[3];
		int base = 0, fill = 0, icon = 0, x = 0, y = 0;
		if (VERSION > 484) {
			base += 2;
		}
		if (VERSION > 508) {
			fill += 6;
			icon += 5;
			x = -1;
			y = 3;
		}
		statusGlobes[base].drawSprite(174, 11 + y);
		statusGlobes[9 + fill].drawSprite(177, 14 + y);
		statusGlobes[8].drawSpriteWithDimensions(177, 14 + y,
		27 - (currentStats[3] * 27 / maxStats[3]));
		if (hpPercent > 25) {
			if (VERSION > 508) {
				y -= 1;
			}
			statusGlobes[22 + icon].drawSprite(183, 22 + y);
		} else {
			if (VERSION > 508) {
				y -= 1;
			}
			if (Client.loopCycle % 25 <= 20) {
				statusGlobes[22 + icon].drawSprite(183, 22 + y, 128);
			}
			if (Client.loopCycle % 25 <= 15) {
				statusGlobes[22 + icon].drawSprite(183, 22 + y);
			}
			if (Client.loopCycle % 25 <= 5) {
				statusGlobes[22 + icon].drawSprite(183, 22 + y, 128);
			}
		}
		if (VERSION == 484) {
			smallText.drawCenteredText("" + currentStats[3], 218, 39,
			calcGlobeTextColor(hpPercent), true);
		} else {
			smallText.drawCenteredText("" + currentStats[3], 217 + x, 37 + y,
			calcGlobeTextColor(hpPercent), true);
		}
		// Prayer globe.
		int prayerPercent = 100 * currentStats[5] / maxStats[5];
		statusGlobes[base].drawSprite(190, 50 + y);
		statusGlobes[10 + fill].drawSprite(193, 53 + y);
		statusGlobes[8 + fill].drawSpriteWithDimensions(193, 53 + y,
		27 - (currentStats[5] * 27 / maxStats[5]));
		if (VERSION == 484) {
			statusGlobes[23].drawSprite(196, 57);
			smallText.drawCenteredText("" + currentStats[5], 235, 78,
			calcGlobeTextColor(prayerPercent), true);
		} else {
			statusGlobes[23 + icon].drawSprite(197, 57 + y);
			smallText.drawCenteredText("" + currentStats[5], 233, 76 + y,
			calcGlobeTextColor(prayerPercent), true);
		}
		// Run globe.
		int runPercent = playerEnergy;
		switch (VERSION) {
			case 484:
				statusGlobes[statusGlobesHover].drawSprite(190, 89);
				if (isRunning == false) {
					statusGlobes[11].drawSprite(193, 92);
					statusGlobes[8].drawSpriteWithDimensions(193, 92, 27 - (runPercent * 27 / 100));
					statusGlobes[24].drawSprite(200, 97);
				} else {
					statusGlobes[13].drawSprite(193, 92);
					statusGlobes[8].drawSpriteWithDimensions(193, 92, 27 - (runPercent * 27 / 100));
					statusGlobes[25].drawSprite(200, 97);
				}
				smallText.drawCenteredText("" + playerEnergy, 235, 117,
				calcGlobeTextColor(runPercent), true);
				break;
			case 508:
				if (isRunning == false) {
					statusGlobes[4 + statusGlobesHover].drawSprite(190, 89);
				} else {
					statusGlobes[6 + statusGlobesHover].drawSprite(190, 89);
				}
				smallText.drawCenteredText("" + playerEnergy, 231, 115,
				calcGlobeTextColor(runPercent), true);
				break;
			case 562:
				statusGlobes[2 + statusGlobesHover].drawSprite(190, 92);
				if (isRunning == false) {
					statusGlobes[17].drawSprite(193, 95);
					statusGlobes[8].drawSpriteWithDimensions(193, 95, 27 - (runPercent * 27 / 100));
					statusGlobes[29].drawSprite(200, 100);
				} else {
					statusGlobes[20].drawSprite(193, 95);
					statusGlobes[8].drawSpriteWithDimensions(193, 95, 27 - (runPercent * 27 / 100));
					statusGlobes[25].drawSprite(200, 100);
				}
				smallText.drawCenteredText("" + playerEnergy, 231, 118,
				calcGlobeTextColor(runPercent), true);
				break;
		}
	}

	private void drawInventoryHover() {
		if (VERSION > 508) {
			switch (inventoryHover) {
				case 0:
				case 1:
				case 2:
					hoverStones[5].drawSprite((30 * inventoryHover) + 6, 0);
					break;
				case 3:
				case 4:
				case 5:
				case 6:
					hoverStones[5].drawSprite((30 * inventoryHover) + 36, 0);
					break;
				case 15:
					hoverStones[5].drawSprite(96, 0);
					break;
				case 7:
					hoverStones[5].drawSprite(96, 298);
					break;
				case 8:
				case 9:
				case 10:
				case 11:
				case 12:
				case 13:
					hoverStones[5].drawSprite((30 * (inventoryHover - 7)) + 6, 298);
					break;
			}
		}
	}

	private void drawInventory() {
		inventoryCanvas.init();
		Renderer3D.lineOffsets = inventoryTexturePool;
		inventory[getImageId()].drawSprite(0, 0);
		if (invOverlayInterfaceID == -1) {
			//if (tabID != inventoryHover) {
			drawInventoryHover();
			//}
			drawRedStones();
			drawSideIcons();
		}
		if (invOverlayInterfaceID != -1) {
			drawInterface(0, 31, Interface.interfaceCache[invOverlayInterfaceID], 37);
		} else if (tabInterfaceIDs[tabID] != -1) {
			drawInterface(0, 31, Interface.interfaceCache[tabInterfaceIDs[tabID]], 37);
		}
		if (menuOpen) {
			drawMenu(516, 164);
		}
		inventoryCanvas.drawGraphics(super.graphics, 516, 168);
		gameScreenCanvas.init();
		Renderer3D.lineOffsets = gameScreenTexturePool;
	}

	private void drawTooltip() {
		if ((menuActionRow < 2) && (itemSelected == 0) && (spellSelected == 0)) {
			return;
		}
		String s;
		if ((itemSelected == 1) && (menuActionRow < 2)) {
			s = "Use " + selectedItemName + " with...";
		} else if ((spellSelected == 1) && (menuActionRow < 2)) {
			s = spellTooltip + "...";
		} else {
			s = menuActionName[menuActionRow - 1];
		}
		if (menuActionRow > 2) {
			s = s + "@whi@ / " + (menuActionRow - 2) + " more options";
		}
		boldText.method390(4, 0xffffff, s, Client.loopCycle / 1000, 15);
	}

	private void dropClient() {
		if (anInt1011 > 0) {
			resetLogout();
			return;
		}
		gameScreenCanvas.init();
		plainText.drawCenteredText("Connection lost", 257, 144, 0);
		plainText.drawCenteredText("Connection lost", 256, 143, 0xffffff);
		plainText.drawCenteredText("Please wait - attempting to reestablish", 257, 159, 0);
		plainText.drawCenteredText("Please wait - attempting to reestablish", 256, 158, 0xffffff);
		gameScreenCanvas.drawGraphics(super.graphics, 4, 4);
		anInt1021 = 0;
		destX = 0;
		Socket socket = socketStream;
		Client.loggedIn = false;
		loginFailures = 0;
		login(myUsername, myPassword, true);
		if (!Client.loggedIn) {
			resetLogout();
		}
		try {
			socket.close();
		} catch (Exception _ex) {
		}
	}

	private int extractInterfaceValues(Interface gi, int value) {
		if ((gi.valueIndexArray == null) || (value >= gi.valueIndexArray.length)) {
			return -2;
		}
		try {
			int ai[] = gi.valueIndexArray[value];
			int k = 0;
			int l = 0;
			int i1 = 0;
			do {
				int j1 = ai[l++];
				int k1 = 0;
				byte byte0 = 0;
				if (j1 == 0) {
					return k;
				}
				if (j1 == 1) {
					k1 = currentStats[ai[l++]];
				}
				if (j1 == 2) {
					k1 = maxStats[ai[l++]];
				}
				if (j1 == 3) {
					k1 = currentExp[ai[l++]];
				}
				if (j1 == 4) {
					Interface iComponent = Interface.interfaceCache[ai[l++]];
					int k2 = ai[l++];
					if ((k2 >= 0) && (k2 < ItemDefinition.totalItems)
					&& (!ItemDefinition.forID(k2).membersObject || Client.isMembers)) {
						for (int j3 = 0; j3 < iComponent.inv.length; j3++) {
							if (iComponent.inv[j3] == k2 + 1) {
								k1 += iComponent.invStackSizes[j3];
							}
						}
					}
				}
				if (j1 == 5) {
					k1 = variousSettings[ai[l++]];
				}
				if (j1 == 6) {
					k1 = Client.anIntArray1019[maxStats[ai[l++]] - 1];
				}
				if (j1 == 7) {
					k1 = (variousSettings[ai[l++]] * 100) / 46875;
				}
				if (j1 == 8) {
					k1 = Client.myPlayer.combatLevel;
				}
				if (j1 == 9) {
					for (int l1 = 0; l1 < Skills.skillsCount; l1++) {
						if (Skills.skillEnabled[l1]) {
							k1 += maxStats[l1];
						}
					}
				}
				if (j1 == 10) {
					Interface iComponent = Interface.interfaceCache[ai[l++]];
					int l2 = ai[l++] + 1;
					if ((l2 >= 0) && (l2 < ItemDefinition.totalItems)
					&& (!ItemDefinition.forID(l2).membersObject || Client.isMembers)) {
						for (int element : iComponent.inv) {
							if (element != l2) {
								continue;
							}
							k1 = 0x3b9ac9ff;
							break;
						}
					}
				}
				if (j1 == 11) {
					k1 = playerEnergy;
				}
				if (j1 == 12) {
					k1 = weight;
				}
				if (j1 == 13) {
					int i2 = variousSettings[ai[l++]];
					int i3 = ai[l++];
					k1 = (i2 & 1 << i3) == 0 ? 0 : 1;
				}
				if (j1 == 14) {
					int j2 = ai[l++];
					VarBit varBit = VarBit.cache[j2];
					int l3 = varBit.anInt648;
					int i4 = varBit.anInt649;
					int j4 = varBit.anInt650;
					int k4 = Client.anIntArray1232[j4 - i4];
					k1 = variousSettings[l3] >> i4 & k4;
				}
				if (j1 == 15) {
					byte0 = 1;
				}
				if (j1 == 16) {
					byte0 = 2;
				}
				if (j1 == 17) {
					byte0 = 3;
				}
				if (j1 == 18) {
					k1 = (Client.myPlayer.x >> 7) + baseX;
				}
				if (j1 == 19) {
					k1 = (Client.myPlayer.y >> 7) + baseY;
				}
				if (j1 == 20) {
					k1 = ai[l++];
				}
				if (byte0 == 0) {
					if (i1 == 0) {
						k += k1;
					}
					if (i1 == 1) {
						k -= k1;
					}
					if ((i1 == 2) && (k1 != 0)) {
						k /= k1;
					}
					if (i1 == 3) {
						k *= k1;
					}
					i1 = 0;
				} else {
					i1 = byte0;
				}
			} while (true);
		} catch (Exception _ex) {
			return -1;
		}
	}

	@Override
	public AppletContext getAppletContext() {
		if (Signlink.mainapp != null) {
			return Signlink.mainapp.getAppletContext();
		} else {
			return super.getAppletContext();
		}
	}

	private Archive getArchiveName(int i, String s, String s1, int j, int k) {
		byte destData[] = null;
		int l = 5;
		try {
			if (cacheIndices[0] != null) {
				destData = cacheIndices[0].get(i);
			}
		} catch (Exception _ex) {
		}
		if (destData != null) {
			// aCRC32_930.reset();
			// aCRC32_930.update(abyte0);
			// int i1 = (int)aCRC32_930.getValue();
			// if(i1 != j)
		}
		if (destData != null) {
			Archive archive = new Archive(destData);
			return archive;
		}
		int j1 = 0;
		while (destData == null) {
			String s2 = "Unknown error";
			drawLoadingText(k, "Requesting " + s);
			try {
				int k1 = 0;
				DataInputStream datainputstream = openJagGrabInputStream(s1 + j);
				byte srcData[] = new byte[6];
				datainputstream.readFully(srcData, 0, 6);
				Packet buffer = new Packet(srcData);
				buffer.offset = 3;
				int i2 = buffer.get24BitInt() + 6;
				int j2 = 6;
				destData = new byte[i2];
				System.arraycopy(srcData, 0, destData, 0, 6);
				while (j2 < i2) {
					int l2 = i2 - j2;
					if (l2 > 1000) {
						l2 = 1000;
					}
					int j3 = datainputstream.read(destData, j2, l2);
					if (j3 < 0) {
						s2 = "Length error: " + j2 + "/" + i2;
						throw new IOException("EOF");
					}
					j2 += j3;
					int k3 = (j2 * 100) / i2;
					if (k3 != k1) {
						drawLoadingText(k, "Loading " + s + " - " + k3 + "%");
					}
					k1 = k3;
				}
				datainputstream.close();
				try {
					if (cacheIndices[0] != null) {
						cacheIndices[0].store(destData.length, destData, i);
					}
				} catch (Exception _ex) {
					cacheIndices[0] = null;
				}
				/*
				 * if(abyte0 != null) { aCRC32_930.reset();
				 * aCRC32_930.update(abyte0); int i3 =
				 * (int)aCRC32_930.getValue(); if(i3 != j) { abyte0 = null;
				 * j1++; s2 = "Checksum error: " + i3; } }
				 */
			} catch (IOException ioexception) {
				if (s2.equals("Unknown error")) {
					s2 = "Connection error";
				}
				destData = null;
			} catch (NullPointerException _ex) {
				s2 = "Null error";
				destData = null;
				if (!Signlink.reporterror) {
					return null;
				}
			} catch (ArrayIndexOutOfBoundsException _ex) {
				s2 = "Bounds error";
				destData = null;
				if (!Signlink.reporterror) {
					return null;
				}
			} catch (Exception _ex) {
				s2 = "Unexpected error";
				destData = null;
				if (!Signlink.reporterror) {
					return null;
				}
			}
			if (destData == null) {
				for (int l1 = l; l1 > 0; l1--) {
					if (j1 >= 3) {
						drawLoadingText(k, "Game updated - please reload page");
						l1 = 10;
					} else {
						drawLoadingText(k, s2 + " - Retrying in " + l1);
					}
					try {
						Thread.sleep(1000L);
					} catch (Exception _ex) {
					}
				}
				l *= 2;
				if (l > 60) {
					l = 60;
				}
				aBoolean872 = !aBoolean872;
			}
		}
		Archive archive = new Archive(destData);
		return archive;
	}

	@Override
	public URL getCodeBase() {
		try {
			return new URL(Client.server + ":" + (80 + Client.portOff));
		} catch (Exception _ex) {
		}
		return null;
	}

	public String getDocumentBaseHost() {
		if (Signlink.mainapp != null) {
			return Signlink.mainapp.getDocumentBase().getHost().toLowerCase();
		}
		if (super.frame != null) {
			return "runescape.com";
		} else {
			return super.getDocumentBase().getHost().toLowerCase();
		}
	}

	@Override
	Component getGameComponent() {
		if (Signlink.mainapp != null) {
			return Signlink.mainapp;
		}
		if (super.frame != null) {
			return super.frame;
		} else {
			return this;
		}
	}

	public byte[] getModel(int index, String dir) {
		try {
			File model = new File(Signlink.findcachedir() + dir + index + ".gz");
			byte[] data = new byte[(int) model.length()];
			FileInputStream fis = new FileInputStream(model);
			fis.read(data);
			fis.close();
			return data;
		} catch (Exception e) {
			return null;
		}
	}

	@Override
	public String getParameter(String s) {
		if (Signlink.mainapp != null) {
			return Signlink.mainapp.getParameter(s);
		} else {
			return super.getParameter(s);
		}
	}

	public int getImageId() {
		if (VERSION == 484) {
			return 0;
		}
		if (VERSION == 508) {
			return 1;
		}
		if (VERSION == 562) {
			return 2;
		}
		if (VERSION == 474) {
			return 3;
		} else {
			return 0;
		}
	}

	@Override
	public void init() {
		Client.nodeID = 10;
		Client.portOff = 0;
		Client.setHighMem();
		Client.isMembers = true;
		initClientFrame(503, 765);
	}

	private String interfaceIntToString(int j) {
		if (j < 0x3b9ac9ff) {
			return String.valueOf(j);
		} else {
			return "*";
		}
	}

	private boolean interfaceIsSelected(Interface iComponent) {
		if (iComponent.anIntArray245 == null) {
			return false;
		}
		for (int i = 0; i < iComponent.anIntArray245.length; i++) {
			int j = extractInterfaceValues(iComponent, i);
			int k = iComponent.anIntArray212[i];
			if (iComponent.anIntArray245[i] == 2) {
				if (j >= k) {
					return false;
				}
			} else if (iComponent.anIntArray245[i] == 3) {
				if (j <= k) {
					return false;
				}
			} else if (iComponent.anIntArray245[i] == 4) {
				if (j == k) {
					return false;
				}
			} else if (j != k) {
				return false;
			}
		}
		return true;
	}

	private boolean isFriendOrSelf(String s) {
		if (s == null) {
			return false;
		}
		for (int i = 0; i < friendsCount; i++) {
			if (s.equalsIgnoreCase(friendsList[i])) {
				return true;
			}
		}
		return s.equalsIgnoreCase(Client.myPlayer.name);
	}

	private void loadError() {
		String s = "ondemand";// was a constant parameter
		System.out.println(s);
		try {
			getAppletContext().showDocument(new URL(getCodeBase(), "loaderror_" + s + ".html"));
		} catch (Exception exception) {
			exception.printStackTrace();
		}
		do {
			try {
				Thread.sleep(1000L);
			} catch (Exception _ex) {
			}
		} while (true);
	}

	private void loadingStages() {
		if (Client.lowMem && (loadingStage == 2) && (Region.anInt131 != plane)) {
			gameScreenCanvas.init();
			plainText.drawCenteredText("Loading - please wait.", 257, 151, 0);
			plainText.drawCenteredText("Loading - please wait.", 256, 150, 0xffffff);
			gameScreenCanvas.drawGraphics(super.graphics, 4, 4);
			loadingStage = 1;
			aLong824 = System.currentTimeMillis();
		}
		if (loadingStage == 1) {
			int j = method54();
			if ((j != 0) && (System.currentTimeMillis() - aLong824 > 0x57e40L)) {
				Signlink.reporterror(myUsername + " glcfb " + aLong1215 + "," + j + ","
				+ Client.lowMem + "," + cacheIndices[0] + "," + onDemandFetcher.getNodeCount()
				+ "," + plane + "," + anInt1069 + "," + anInt1070);
				aLong824 = System.currentTimeMillis();
			}
		}
		if ((loadingStage == 2) && (plane != anInt985)) {
			anInt985 = plane;
			method24(plane);
		}
	}

	private void loadTitleScreen() {
		titleBox = new IndexedSprite(titleArchive, "titlebox", 0);
		titleButton = new IndexedSprite(titleArchive, "titlebutton", 0);
		runes = new IndexedSprite[12];
		int j = 0;
		try {
			j = Integer.parseInt(getParameter("fl_icon"));
		} catch (Exception _ex) {
		}
		if (j == 0) {
			for (int k = 0; k < 12; k++) {
				runes[k] = new IndexedSprite(titleArchive, "runes", k);
			}
		} else {
			for (int l = 0; l < 12; l++) {
				runes[l] = new IndexedSprite(titleArchive, "runes", 12 + (l & 3));
			}
		}
		leftFlame = new Sprite(128, 265);
		rightFlame = new Sprite(128, 265);
		System.arraycopy(leftFlameCanvas.componentPixels, 0, leftFlame.pixels, 0, 33920);
		System.arraycopy(rightFlameCanvas.componentPixels, 0, rightFlame.pixels, 0, 33920);
		anIntArray851 = new int[256];
		for (int k1 = 0; k1 < 64; k1++) {
			anIntArray851[k1] = k1 * 0x40000;
		}
		for (int l1 = 0; l1 < 64; l1++) {
			anIntArray851[l1 + 64] = 0xff0000 + 1024 * l1;
		}
		for (int i2 = 0; i2 < 64; i2++) {
			anIntArray851[i2 + 128] = 0xffff00 + 4 * i2;
		}
		for (int j2 = 0; j2 < 64; j2++) {
			anIntArray851[j2 + 192] = 0xffffff;
		}
		anIntArray852 = new int[256];
		for (int k2 = 0; k2 < 64; k2++) {
			anIntArray852[k2] = k2 * 1024;
		}
		for (int l2 = 0; l2 < 64; l2++) {
			anIntArray852[l2 + 64] = 65280 + 4 * l2;
		}
		for (int i3 = 0; i3 < 64; i3++) {
			anIntArray852[i3 + 128] = 65535 + 0x40000 * i3;
		}
		for (int j3 = 0; j3 < 64; j3++) {
			anIntArray852[j3 + 192] = 0xffffff;
		}
		anIntArray853 = new int[256];
		for (int k3 = 0; k3 < 64; k3++) {
			anIntArray853[k3] = k3 * 4;
		}
		for (int l3 = 0; l3 < 64; l3++) {
			anIntArray853[l3 + 64] = 255 + 0x40000 * l3;
		}
		for (int i4 = 0; i4 < 64; i4++) {
			anIntArray853[i4 + 128] = 0xff00ff + 1024 * i4;
		}
		for (int j4 = 0; j4 < 64; j4++) {
			anIntArray853[j4 + 192] = 0xffffff;
		}
		anIntArray850 = new int[256];
		anIntArray1190 = new int[32768];
		anIntArray1191 = new int[32768];
		randomizeImage(null);
		anIntArray828 = new int[32768];
		anIntArray829 = new int[32768];
		drawLoadingText(10, "Connecting to fileserver");
		if (!flameRequest) {
			drawFlames = true;
			flameRequest = true;
			startRunnable(this, 2);
		}
	}

	private void login(String s, String s1, boolean flag) {
		Signlink.errorname = s;
		try {
			if (!flag) {
				loginMessage1 = "";
				loginMessage2 = "Connecting to server...";
				drawTitlebox(true);
			}
			socketStream = new Socket(this, openSocket(43594 + Client.portOff));
			long l = TextUtil.longForName(s);
			int i = (int) (l >> 16 & 31L);
			outputStream.offset = 0;
			outputStream.putByte(14);
			outputStream.putByte(i);
			socketStream.queueBytes(2, outputStream.buffer);
			for (int j = 0; j < 8; j++) {
				socketStream.read();
			}
			int k = socketStream.read();
			int i1 = k;
			if (k == 0) {
				socketStream.flushInputStream(inputStream.buffer, 8);
				inputStream.offset = 0;
				aLong1215 = inputStream.getLong();
				int ai[] = new int[4];
				ai[0] = (int) (Math.random() * 99999999D);
				ai[1] = (int) (Math.random() * 99999999D);
				ai[2] = (int) (aLong1215 >> 32);
				ai[3] = (int) aLong1215;
				outputStream.offset = 0;
				outputStream.putByte(10);
				outputStream.putInt(ai[0]);
				outputStream.putInt(ai[1]);
				outputStream.putInt(ai[2]);
				outputStream.putInt(ai[3]);
				outputStream.putInt(Signlink.uid);
				outputStream.putString(s);
				outputStream.putString(s1);
				outputStream.encodeRsa();
				settingsBuffers.offset = 0;
				if (flag) {
					settingsBuffers.putByte(18);
				} else {
					settingsBuffers.putByte(16);
				}
				settingsBuffers.putByte(outputStream.offset + 36 + 1 + 1 + 2);
				settingsBuffers.putByte(255);
				settingsBuffers.putShort(317);
				settingsBuffers.putByte(Client.lowMem ? 1 : 0);
				for (int l1 = 0; l1 < 9; l1++) {
					settingsBuffers.putInt(expectedCRCs[l1]);
				}
				settingsBuffers.putBytes(outputStream.buffer, 0, outputStream.offset);
				outputStream.packetCryption = new IsaacCipher(ai);
				for (int j2 = 0; j2 < 4; j2++) {
					ai[j2] += 50;
				}
				encryption = new IsaacCipher(ai);
				socketStream.queueBytes(settingsBuffers.offset, settingsBuffers.buffer);
				k = socketStream.read();
			}
			if (k == 1) {
				try {
					Thread.sleep(2000L);
				} catch (Exception _ex) {
				}
				login(s, s1, flag);
				return;
			}
			if (k == 2) {
				myPrivilege = socketStream.read();
				Client.flagged = socketStream.read() == 1;
				aLong1220 = 0L;
				anInt1022 = 0;
				mouseDetection.coordsIndex = 0;
				super.awtFocus = true;
				aBoolean954 = true;
				Client.loggedIn = true;
				outputStream.offset = 0;
				inputStream.offset = 0;
				packetType = -1;
				anInt841 = -1;
				anInt842 = -1;
				anInt843 = -1;
				packetSize = 0;
				anInt1009 = 0;
				anInt1104 = 0;
				anInt1011 = 0;
				anInt855 = 0;
				menuActionRow = 0;
				menuOpen = false;
				super.idleTime = 0;
				for (int j1 = 0; j1 < 100; j1++) {
					chatMessages[j1] = null;
				}
				itemSelected = 0;
				spellSelected = 0;
				loadingStage = 0;
				anInt1062 = 0;
				anInt1278 = (int) (Math.random() * 100D) - 50;
				anInt1131 = (int) (Math.random() * 110D) - 55;
				anInt896 = (int) (Math.random() * 80D) - 40;
				minimapRotation = (int) (Math.random() * 120D) - 60;
				minimapZoom = (int) (Math.random() * 30D) - 20;
				minimapAndCompassRotation = (int) (Math.random() * 20D) - 10 & 0x7ff;
				anInt1021 = 0;
				anInt985 = -1;
				destX = 0;
				destY = 0;
				playerCount = 0;
				npcCount = 0;
				for (int i2 = 0; i2 < maxPlayers; i2++) {
					playerArray[i2] = null;
					playerAppearanceBuffers[i2] = null;
				}
				for (int k2 = 0; k2 < 16384; k2++) {
					npcArray[k2] = null;
				}
				Client.myPlayer = playerArray[myPlayerIndex] = new Player();
				projectileList.clear();
				stillGraphicList.clear();
				for (int l2 = 0; l2 < 4; l2++) {
					for (int i3 = 0; i3 < 104; i3++) {
						for (int k3 = 0; k3 < 104; k3++) {
							groundArray[l2][i3][k3] = null;
						}
					}
				}
				aClass19_1179 = new Deque();
				fullscreenInterfaceID = -1;
				anInt900 = 0;
				friendsCount = 0;
				dialogID = -1;
				backDialogID = -1;
				openInterfaceID = -1;
				invOverlayInterfaceID = -1;
				anInt1018 = -1;
				aBoolean1149 = false;
				tabID = 3;
				inputDialogState = 0;
				menuOpen = false;
				messagePromptRaised = false;
				continueMessageTitle = null;
				anInt1055 = 0;
				anInt1054 = -1;
				aBoolean1047 = true;
				method45();
				for (int j3 = 0; j3 < 5; j3++) {
					anIntArray990[j3] = 0;
				}
				for (int l3 = 0; l3 < 5; l3++) {
					atPlayerActions[l3] = null;
					atPlayerArray[l3] = false;
				}
				Client.anInt1175 = 0;
				Client.anInt1134 = 0;
				Client.anInt986 = 0;
				Client.anInt1288 = 0;
				Client.anInt924 = 0;
				Client.anInt1188 = 0;
				Client.anInt1155 = 0;
				Client.anInt1226 = 0;
				resetGameScreenGraphicsBuffers();
				return;
			}
			if (k == 3) {
				loginMessage1 = "";
				loginMessage2 = "Invalid username or password.";
				return;
			}
			if (k == 4) {
				loginMessage1 = "Your account has been disabled.";
				loginMessage2 = "Please check your message-center for details.";
				return;
			}
			if (k == 5) {
				loginMessage1 = "Your account is already logged in.";
				loginMessage2 = "Try again in 60 secs...";
				return;
			}
			if (k == 6) {
				loginMessage1 = "RuneScape has been updated!";
				loginMessage2 = "Please reload this page.";
				return;
			}
			if (k == 7) {
				loginMessage1 = "This world is full.";
				loginMessage2 = "Please use a different world.";
				return;
			}
			if (k == 8) {
				loginMessage1 = "Unable to connect.";
				loginMessage2 = "Login server offline.";
				return;
			}
			if (k == 9) {
				loginMessage1 = "Login limit exceeded.";
				loginMessage2 = "Too many connections from your address.";
				return;
			}
			if (k == 10) {
				loginMessage1 = "Unable to connect.";
				loginMessage2 = "Bad session id.";
				return;
			}
			if (k == 11) {
				loginMessage2 = "Login server rejected session.";
				loginMessage2 = "Please try again.";
				return;
			}
			if (k == 12) {
				loginMessage1 = "You need a members account to login to this world.";
				loginMessage2 = "Please subscribe, or use a different world.";
				return;
			}
			if (k == 13) {
				loginMessage1 = "Could not complete login.";
				loginMessage2 = "Please try using a different world.";
				return;
			}
			if (k == 14) {
				loginMessage1 = "The server is being updated.";
				loginMessage2 = "Please wait 1 minute and try again.";
				return;
			}
			if (k == 15) {
				Client.loggedIn = true;
				outputStream.offset = 0;
				inputStream.offset = 0;
				packetType = -1;
				anInt841 = -1;
				anInt842 = -1;
				anInt843 = -1;
				packetSize = 0;
				anInt1009 = 0;
				anInt1104 = 0;
				menuActionRow = 0;
				menuOpen = false;
				aLong824 = System.currentTimeMillis();
				return;
			}
			if (k == 16) {
				loginMessage1 = "Login attempts exceeded.";
				loginMessage2 = "Please wait 1 minute and try again.";
				return;
			}
			if (k == 17) {
				loginMessage1 = "You are standing in a members-only area.";
				loginMessage2 = "To play on this world move to a free area first";
				return;
			}
			if (k == 20) {
				loginMessage1 = "Invalid loginserver requested";
				loginMessage2 = "Please try using a different world.";
				return;
			}
			if (k == 21) {
				for (int k1 = socketStream.read(); k1 >= 0; k1--) {
					loginMessage1 = "You have only just left another world";
					loginMessage2 = "Your profile will be transferred in: " + k1 + " seconds";
					drawTitlebox(true);
					try {
						Thread.sleep(1000L);
					} catch (Exception _ex) {
					}
				}
				login(s, s1, flag);
				return;
			}
			if (k == -1) {
				if (i1 == 0) {
					if (loginFailures < 2) {
						try {
							Thread.sleep(2000L);
						} catch (Exception _ex) {
						}
						loginFailures++;
						login(s, s1, flag);
						return;
					} else {
						loginMessage1 = "No response from loginserver";
						loginMessage2 = "Please wait 1 minute and try again.";
						return;
					}
				} else {
					loginMessage1 = "No response from server";
					loginMessage2 = "Please try using a different world.";
					return;
				}
			} else {
				System.out.println("response:" + k);
				loginMessage1 = "Unexpected server response";
				loginMessage2 = "Please try using a different world.";
				return;
			}
		} catch (IOException _ex) {
			loginMessage1 = "";
		}
		loginMessage2 = "Error connecting to server.";
	}

	private void mainGameProcessor() {
		if (anInt1104 > 1) {
			anInt1104--;
		}
		if (anInt1011 > 0) {
			anInt1011--;
		}
		for (int j = 0; j < 5; j++) {
			if (!parsePacket()) {
				break;
			}
		}
		if (!Client.loggedIn) {
			return;
		}
		synchronized (mouseDetection.syncObject) {
			if (Client.flagged) {
				if ((super.clickMode3 != 0) || (mouseDetection.coordsIndex >= 40)) {
					outputStream.putOperation(45);
					outputStream.putByte(0);
					int j2 = outputStream.offset;
					int j3 = 0;
					for (int j4 = 0; j4 < mouseDetection.coordsIndex; j4++) {
						if (j2 - outputStream.offset >= 240) {
							break;
						}
						j3++;
						int l4 = mouseDetection.coordsY[j4];
						if (l4 < 0) {
							l4 = 0;
						} else if (l4 > 502) {
							l4 = 502;
						}
						int k5 = mouseDetection.coordsX[j4];
						if (k5 < 0) {
							k5 = 0;
						} else if (k5 > 764) {
							k5 = 764;
						}
						int i6 = l4 * 765 + k5;
						if ((mouseDetection.coordsY[j4] == -1)
						&& (mouseDetection.coordsX[j4] == -1)) {
							k5 = -1;
							l4 = -1;
							i6 = 0x7ffff;
						}
						if ((k5 == anInt1237) && (l4 == anInt1238)) {
							if (anInt1022 < 2047) {
								anInt1022++;
							}
						} else {
							int j6 = k5 - anInt1237;
							anInt1237 = k5;
							int k6 = l4 - anInt1238;
							anInt1238 = l4;
							if ((anInt1022 < 8) && (j6 >= -32) && (j6 <= 31) && (k6 >= -32)
							&& (k6 <= 31)) {
								j6 += 32;
								k6 += 32;
								outputStream.putShort((anInt1022 << 12) + (j6 << 6) + k6);
								anInt1022 = 0;
							} else if (anInt1022 < 8) {
								outputStream.put24BitInt(0x800000 + (anInt1022 << 19) + i6);
								anInt1022 = 0;
							} else {
								outputStream.putInt(0xc0000000 + (anInt1022 << 19) + i6);
								anInt1022 = 0;
							}
						}
					}
					outputStream.putSizeByte(outputStream.offset - j2);
					if (j3 >= mouseDetection.coordsIndex) {
						mouseDetection.coordsIndex = 0;
					} else {
						mouseDetection.coordsIndex -= j3;
						for (int i5 = 0; i5 < mouseDetection.coordsIndex; i5++) {
							mouseDetection.coordsX[i5] = mouseDetection.coordsX[i5 + j3];
							mouseDetection.coordsY[i5] = mouseDetection.coordsY[i5 + j3];
						}
					}
				}
			} else {
				mouseDetection.coordsIndex = 0;
			}
		}
		if (super.clickMode3 != 0) {
			long l = (super.aLong29 - aLong1220) / 50L;
			if (l > 4095L) {
				l = 4095L;
			}
			aLong1220 = super.aLong29;
			int k2 = super.saveClickY;
			if (k2 < 0) {
				k2 = 0;
			} else if (k2 > 502) {
				k2 = 502;
			}
			int k3 = super.saveClickX;
			if (k3 < 0) {
				k3 = 0;
			} else if (k3 > 764) {
				k3 = 764;
			}
			int k4 = k2 * 765 + k3;
			int j5 = 0;
			if (super.clickMode3 == 2) {
				j5 = 1;
			}
			int l5 = (int) l;
			outputStream.putOperation(241);
			outputStream.putInt((l5 << 20) + (j5 << 19) + k4);
		}
		if (anInt1016 > 0) {
			anInt1016--;
		}
		if ((super.keyArray[1] == 1) || (super.keyArray[2] == 1) || (super.keyArray[3] == 1)
		|| (super.keyArray[4] == 1)) {
			aBoolean1017 = true;
		}
		if (aBoolean1017 && (anInt1016 <= 0)) {
			anInt1016 = 20;
			aBoolean1017 = false;
			outputStream.putOperation(86);
			outputStream.putShort(anInt1184);
			outputStream.putShortA(minimapAndCompassRotation);
		}
		if (super.awtFocus && !aBoolean954) {
			aBoolean954 = true;
			outputStream.putOperation(3);
			outputStream.putByte(1);
		}
		if (!super.awtFocus && aBoolean954) {
			aBoolean954 = false;
			outputStream.putOperation(3);
			outputStream.putByte(0);
		}
		loadingStages();
		method115();
		method90();
		anInt1009++;
		if (anInt1009 > 750) {
			dropClient();
		}
		method114();
		method95();
		method38();
		anInt945++;
		if (crossType != 0) {
			crossIndex += 20;
			if (crossIndex >= 400) {
				crossType = 0;
			}
		}
		if (atInventoryInterfaceType != 0) {
			atInventoryLoopCycle++;
			if (atInventoryLoopCycle >= 15) {
				if (atInventoryInterfaceType == 2) {
					drawInventoryRequest = true;
				}
				if (atInventoryInterfaceType == 3) {
					Client.inputTaken = true;
				}
				atInventoryInterfaceType = 0;
			}
		}
		if (activeInterfaceType != 0) {
			anInt989++;
			if ((super.mouseX > anInt1087 + 5) || (super.mouseX < anInt1087 - 5)
			|| (super.mouseY > anInt1088 + 5) || (super.mouseY < anInt1088 - 5)) {
				aBoolean1242 = true;
			}
			if (super.clickMode2 == 0) {
				if (activeInterfaceType == 2) {
					drawInventoryRequest = true;
				}
				if (activeInterfaceType == 3) {
					Client.inputTaken = true;
				}
				activeInterfaceType = 0;
				if (aBoolean1242 && (anInt989 >= 5)) {
					lastActiveInvInterface = -1;
					processRightClick();
					if ((lastActiveInvInterface == anInt1084)
					&& (mouseInvInterfaceIndex != anInt1085)) {
						Interface iComponent = Interface.interfaceCache[anInt1084];
						int j1 = 0;
						if ((anInt913 == 1) && (iComponent.contentType == 206)) {
							j1 = 1;
						}
						if (iComponent.inv[mouseInvInterfaceIndex] <= 0) {
							j1 = 0;
						}
						if (iComponent.aBoolean235) {
							int l2 = anInt1085;
							int l3 = mouseInvInterfaceIndex;
							iComponent.inv[l3] = iComponent.inv[l2];
							iComponent.invStackSizes[l3] = iComponent.invStackSizes[l2];
							iComponent.inv[l2] = -1;
							iComponent.invStackSizes[l2] = 0;
						} else if (j1 == 1) {
							int i3 = anInt1085;
							for (int i4 = mouseInvInterfaceIndex; i3 != i4;) {
								if (i3 > i4) {
									iComponent.swapInventoryItems(i3, i3 - 1);
									i3--;
								} else if (i3 < i4) {
									iComponent.swapInventoryItems(i3, i3 + 1);
									i3++;
								}
							}
						} else {
							iComponent.swapInventoryItems(anInt1085, mouseInvInterfaceIndex);
						}
						outputStream.putOperation(214);
						outputStream.putLEShortA(anInt1084);
						outputStream.putByteC(j1);
						outputStream.putLEShortA(anInt1085);
						outputStream.putLEShort(mouseInvInterfaceIndex);
					}
				} else if (((anInt1253 == 1) || menuHasAddFriend(menuActionRow - 1))
				&& (menuActionRow > 2)) {
					determineMenuSize();
				} else if (menuActionRow > 0) {
					doAction(menuActionRow - 1);
				}
				atInventoryLoopCycle = 10;
				super.clickMode3 = 0;
			}
		}
		if (SceneGraph.anInt470 != -1) {
			int k = SceneGraph.anInt470;
			int k1 = SceneGraph.anInt471;
			boolean flag = doWalkTo(0, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, k1,
			Client.myPlayer.walkQueueX[0], true, k);
			SceneGraph.anInt470 = -1;
			if (flag) {
				crossX = super.saveClickX;
				crossY = super.saveClickY;
				crossType = 1;
				crossIndex = 0;
			}
		}
		if ((super.clickMode3 == 1) && (continueMessageTitle != null)) {
			continueMessageTitle = null;
			Client.inputTaken = true;
			super.clickMode3 = 0;
		}
		if (!processMenuClick()) {
			processMainScreenClick();
			processTabClick();
		}
		if ((super.clickMode2 == 1) || (super.clickMode3 == 1)) {
			anInt1213++;
		}
		if ((anInt1500 != 0) || (anInt1044 != 0) || (anInt1129 != 0)) {
			if (anInt1501 < 100) {
				anInt1501++;
				if (anInt1501 == 100) {
					if (anInt1500 != 0) {
						Client.inputTaken = true;
					}
					if (anInt1044 != 0) {
						drawInventoryRequest = true;
					}
				}
			}
		} else if (anInt1501 > 0) {
			anInt1501--;
		}
		if (loadingStage == 2) {
			method108();
		}
		if ((loadingStage == 2) && aBoolean1160) {
			getCameraPos();
		}
		for (int i1 = 0; i1 < 5; i1++) {
			anIntArray1030[i1]++;
		}
		processPlayerInput();
		super.idleTime++;
		if (super.idleTime > 4500) {
			anInt1011 = 250;
			super.idleTime -= 500;
			outputStream.putOperation(202);
		}
		anInt988++;
		if (anInt988 > 500) {
			anInt988 = 0;
			int l1 = (int) (Math.random() * 8D);
			if ((l1 & 1) == 1) {
				anInt1278 += anInt1279;
			}
			if ((l1 & 2) == 2) {
				anInt1131 += anInt1132;
			}
			if ((l1 & 4) == 4) {
				anInt896 += anInt897;
			}
		}
		if (anInt1278 < -50) {
			anInt1279 = 2;
		}
		if (anInt1278 > 50) {
			anInt1279 = -2;
		}
		if (anInt1131 < -55) {
			anInt1132 = 2;
		}
		if (anInt1131 > 55) {
			anInt1132 = -2;
		}
		if (anInt896 < -40) {
			anInt897 = 1;
		}
		if (anInt896 > 40) {
			anInt897 = -1;
		}
		anInt1254++;
		if (anInt1254 > 500) {
			anInt1254 = 0;
			int i2 = (int) (Math.random() * 8D);
			if ((i2 & 1) == 1) {
				minimapRotation += anInt1210;
			}
			if ((i2 & 2) == 2) {
				minimapZoom += anInt1171;
			}
		}
		if (minimapRotation < -60) {
			anInt1210 = 2;
		}
		if (minimapRotation > 60) {
			anInt1210 = -2;
		}
		if (minimapZoom < -20) {
			anInt1171 = 1;
		}
		if (minimapZoom > 10) {
			anInt1171 = -1;
		}
		anInt1010++;
		if (anInt1010 > 50) {
			outputStream.putOperation(0);
		}
		try {
			if ((socketStream != null) && (outputStream.offset > 0)) {
				socketStream.queueBytes(outputStream.offset, outputStream.buffer);
				outputStream.offset = 0;
				anInt1010 = 0;
			}
		} catch (IOException _ex) {
			dropClient();
		} catch (Exception exception) {
			resetLogout();
		}
	}

	private void markMinimap(Sprite sprite, int x, int y) {
		int rotation = minimapAndCompassRotation + minimapRotation & 0x7ff;
		int l = x * x + y * y;
		if (l > 6400) {
			return;
		}
		int i1 = Model.sineTable[rotation];
		int j1 = Model.cosineTable[rotation];
		i1 = (i1 * 256) / (minimapZoom + 256);
		j1 = (j1 * 256) / (minimapZoom + 256);
		int k1 = y * i1 + x * j1 >> 16;
		int l1 = y * j1 - x * i1 >> 16;
		if (VERSION > 474) {
			sprite.drawSprite(((108 + k1) - sprite.trimWidth / 2) + 4, 88 - l1 - sprite.trimHeight
			/ 2 - 4);
		} else {
			sprite.drawSprite(((122 + k1) - sprite.trimWidth / 2) + 4, 86 - l1 - sprite.trimHeight
			/ 2 - 4);
		}
	}

	private boolean menuHasAddFriend(int j) {
		if (j < 0) {
			return false;
		}
		int k = menuActionID[j];
		if (k >= 2000) {
			k -= 2000;
		}
		return k == 337;
	}

	private void method100(Entity entity) {
		if (entity.anInt1504 == 0) {
			return;
		}
		if ((entity.interactingEntity != -1) && (entity.interactingEntity < 32768)) {
			Npc npc = npcArray[entity.interactingEntity];
			if (npc != null) {
				int i1 = entity.x - npc.x;
				int k1 = entity.y - npc.y;
				if ((i1 != 0) || (k1 != 0)) {
					entity.turnDirection = (int) (Math.atan2(i1, k1) * 325.94900000000001D) & 0x7ff;
				}
			}
		}
		if (entity.interactingEntity >= 32768) {
			int j = entity.interactingEntity - 32768;
			if (j == unknownInt10) {
				j = myPlayerIndex;
			}
			Player player = playerArray[j];
			if (player != null) {
				int l1 = entity.x - player.x;
				int i2 = entity.y - player.y;
				if ((l1 != 0) || (i2 != 0)) {
					entity.turnDirection = (int) (Math.atan2(l1, i2) * 325.94900000000001D) & 0x7ff;
				}
			}
		}
		if (((entity.anInt1538 != 0) || (entity.anInt1539 != 0))
		&& ((entity.smallXYIndex == 0) || (entity.anInt1503 > 0))) {
			int k = entity.x - (entity.anInt1538 - baseX - baseX) * 64;
			int j1 = entity.y - (entity.anInt1539 - baseY - baseY) * 64;
			if ((k != 0) || (j1 != 0)) {
				entity.turnDirection = (int) (Math.atan2(k, j1) * 325.94900000000001D) & 0x7ff;
			}
			entity.anInt1538 = 0;
			entity.anInt1539 = 0;
		}
		int l = entity.turnDirection - entity.anInt1552 & 0x7ff;
		if (l != 0) {
			if ((l < entity.anInt1504) || (l > 2048 - entity.anInt1504)) {
				entity.anInt1552 = entity.turnDirection;
			} else if (l > 1024) {
				entity.anInt1552 -= entity.anInt1504;
			} else {
				entity.anInt1552 += entity.anInt1504;
			}
			entity.anInt1552 &= 0x7ff;
			if ((entity.anInt1517 == entity.idleAnimation)
			&& (entity.anInt1552 != entity.turnDirection)) {
				if (entity.turnAnimation != -1) {
					entity.anInt1517 = entity.turnAnimation;
					return;
				}
				entity.anInt1517 = entity.walkAnimation;
			}
		}
	}

	private void method101(Entity entity) {
		entity.aBoolean1541 = false;
		if (entity.anInt1517 != -1) {
			Animation animation = Animation.animations[entity.anInt1517];
			entity.anInt1519++;
			if ((entity.anInt1518 < animation.anInt352)
			&& (entity.anInt1519 > animation.method258(entity.anInt1518))) {
				entity.anInt1519 = 0;
				entity.anInt1518++;
			}
			if (entity.anInt1518 >= animation.anInt352) {
				entity.anInt1519 = 0;
				entity.anInt1518 = 0;
			}
		}
		if ((entity.anInt1520 != -1) && (Client.loopCycle >= entity.anInt1523)) {
			if (entity.anInt1521 < 0) {
				entity.anInt1521 = 0;
			}
			Animation animation_1 = SpotAnimation.cache[entity.anInt1520].aAnimation_407;
			for (entity.anInt1522++; (entity.anInt1521 < animation_1.anInt352)
			&& (entity.anInt1522 > animation_1.method258(entity.anInt1521)); entity.anInt1521++) {
				entity.anInt1522 -= animation_1.method258(entity.anInt1521);
			}
			if ((entity.anInt1521 >= animation_1.anInt352)
			&& ((entity.anInt1521 < 0) || (entity.anInt1521 >= animation_1.anInt352))) {
				entity.anInt1520 = -1;
			}
		}
		if ((entity.currentAnimation != -1) && (entity.animationDelay <= 1)) {
			Animation animation_2 = Animation.animations[entity.currentAnimation];
			if ((animation_2.anInt363 == 1) && (entity.anInt1542 > 0)
			&& (entity.anInt1547 <= Client.loopCycle) && (entity.anInt1548 < Client.loopCycle)) {
				entity.animationDelay = 1;
				return;
			}
		}
		if ((entity.currentAnimation != -1) && (entity.animationDelay == 0)) {
			Animation animation_3 = Animation.animations[entity.currentAnimation];
			for (entity.anInt1528++; (entity.anInt1527 < animation_3.anInt352)
			&& (entity.anInt1528 > animation_3.method258(entity.anInt1527)); entity.anInt1527++) {
				entity.anInt1528 -= animation_3.method258(entity.anInt1527);
			}
			if (entity.anInt1527 >= animation_3.anInt352) {
				entity.anInt1527 -= animation_3.anInt356;
				entity.anInt1530++;
				if (entity.anInt1530 >= animation_3.anInt362) {
					entity.currentAnimation = -1;
				}
				if ((entity.anInt1527 < 0) || (entity.anInt1527 >= animation_3.anInt352)) {
					entity.currentAnimation = -1;
				}
			}
			entity.aBoolean1541 = animation_3.aBoolean358;
		}
		if (entity.animationDelay > 0) {
			entity.animationDelay--;
		}
	}

	private void renderStillGraphics() {
		StillGraphic stillGraphic = (StillGraphic) stillGraphicList.getFront();
		for (; stillGraphic != null; stillGraphic = (StillGraphic) stillGraphicList
		.getNext()) {
			if ((stillGraphic.anInt1560 != plane) || stillGraphic.aBoolean1567) {
				stillGraphic.unlink();
			} else if (Client.loopCycle >= stillGraphic.anInt1564) {
				stillGraphic.method454(anInt945);
				if (stillGraphic.aBoolean1567) {
					stillGraphic.unlink();
				} else {
					sceneGraph.method285(stillGraphic.anInt1560, 0, stillGraphic.anInt1563, -1,
					stillGraphic.anInt1562, 60, stillGraphic.anInt1561, stillGraphic, false);
				}
			}
		}
	}

	private void method107(int i, int j, Packet buffer, Player player) {
		if ((i & 0x400) != 0) {
			player.anInt1543 = buffer.getUnsignedByteS();
			player.anInt1545 = buffer.getUnsignedByteS();
			player.anInt1544 = buffer.getUnsignedByteS();
			player.anInt1546 = buffer.getUnsignedByteS();
			player.anInt1547 = buffer.getUnsignedShortA() + Client.loopCycle;
			player.anInt1548 = buffer.getUnsignedLEShortA() + Client.loopCycle;
			player.anInt1549 = buffer.getUnsignedByteS();
			player.method446();
		}
		if ((i & 0x100) != 0) {
			player.anInt1520 = buffer.getUnsignedLEShort();
			int k = buffer.getInt();
			player.anInt1524 = k >> 16;
			player.anInt1523 = Client.loopCycle + (k & 0xffff);
			player.anInt1521 = 0;
			player.anInt1522 = 0;
			if (player.anInt1523 > Client.loopCycle) {
				player.anInt1521 = -1;
			}
			if (player.anInt1520 == 65535) {
				player.anInt1520 = -1;
			}
		}
		if ((i & 8) != 0) {
			int l = buffer.getUnsignedLEShort();
			if (l == 65535) {
				l = -1;
			}
			int i2 = buffer.getUnsignedByteC();
			if ((l == player.currentAnimation) && (l != -1)) {
				int i3 = Animation.animations[l].anInt365;
				if (i3 == 1) {
					player.anInt1527 = 0;
					player.anInt1528 = 0;
					player.animationDelay = i2;
					player.anInt1530 = 0;
				}
				if (i3 == 2) {
					player.anInt1530 = 0;
				}
			} else if ((l == -1)
			|| (player.currentAnimation == -1)
			|| (Animation.animations[l].anInt359 >= Animation.animations[player.currentAnimation].anInt359)) {
				player.currentAnimation = l;
				player.anInt1527 = 0;
				player.anInt1528 = 0;
				player.animationDelay = i2;
				player.anInt1530 = 0;
				player.anInt1542 = player.smallXYIndex;
			}
		}
		if ((i & 4) != 0) {
			player.textSpoken = buffer.getString();
			if (player.textSpoken.charAt(0) == '~') {
				player.textSpoken = player.textSpoken.substring(1);
				pushMessage(player.textSpoken, 2, player.name);
			} else if (player == Client.myPlayer) {
				pushMessage(player.textSpoken, 2, player.name);
			}
			player.anInt1513 = 0;
			player.textEffects = 0;
			player.textCycle = 150;
		}
		if ((i & 0x80) != 0) {
			int i1 = buffer.getUnsignedLEShort();
			int j2 = buffer.getUnsignedByte();
			int j3 = buffer.getUnsignedByteC();
			int k3 = buffer.offset;
			if ((player.name != null) && player.visible) {
				long l3 = TextUtil.longForName(player.name);
				boolean flag = false;
				if (j2 <= 1) {
					for (int i4 = 0; i4 < ignoreCount; i4++) {
						if (ignoreListAsLongs[i4] != l3) {
							continue;
						}
						flag = true;
						break;
					}
				}
				if (!flag && (anInt1251 == 0)) {
					try {
						chatBuffers.offset = 0;
						buffer.getReverseBytes(chatBuffers.buffer, 0, j3);
						chatBuffers.offset = 0;
						String s = ChatInput.method525(j3, chatBuffers);
						// s = Censor.doCensor(s);
						player.textSpoken = s;
						player.anInt1513 = i1 >> 8;
						player.privelage = j2;
						player.textEffects = i1 & 0xff;
						player.textCycle = 150;
						if ((j2 == 2) || (j2 == 3)) {
							pushMessage(s, 1, "@cr2@" + player.name);
						} else if (j2 == 1) {
							pushMessage(s, 1, "@cr1@" + player.name);
						} else {
							pushMessage(s, 2, player.name);
						}
					} catch (Exception exception) {
						Signlink.reporterror("cde2");
					}
				}
			}
			buffer.offset = k3 + j3;
		}
		if ((i & 1) != 0) {
			player.interactingEntity = buffer.getUnsignedLEShort();
			if (player.interactingEntity == 65535) {
				player.interactingEntity = -1;
			}
		}
		if ((i & 0x10) != 0) {
			int j1 = buffer.getUnsignedByteC();
			byte data[] = new byte[j1];
			Packet appearanceBuffer = new Packet(data);
			buffer.getBytes(data, j1, 0);
			playerAppearanceBuffers[j] = appearanceBuffer;
			player.updatePlayer(appearanceBuffer);
		}
		if ((i & 2) != 0) {
			player.anInt1538 = buffer.getUnsignedShortA();
			player.anInt1539 = buffer.getUnsignedLEShort();
		}
		if ((i & 0x20) != 0) {
			int k1 = buffer.getUnsignedByte();
			int k2 = buffer.getUnsignedByteA();
			player.updateHitData(k2, k1, Client.loopCycle);
			player.combatCycle = Client.loopCycle + 300;
			player.currentHealth = buffer.getUnsignedByteC();
			player.maxHealth = buffer.getUnsignedByte();
		}
		if ((i & 0x200) != 0) {
			int l1 = buffer.getUnsignedByte();
			int l2 = buffer.getUnsignedByteS();
			player.updateHitData(l2, l1, Client.loopCycle);
			player.combatCycle = Client.loopCycle + 300;
			player.currentHealth = buffer.getUnsignedByte();
			player.maxHealth = buffer.getUnsignedByteC();
		}
	}

	private void method108() {
		try {
			int j = Client.myPlayer.x + anInt1278;
			int k = Client.myPlayer.y + anInt1131;
			if ((anInt1014 - j < -500) || (anInt1014 - j > 500) || (anInt1015 - k < -500)
			|| (anInt1015 - k > 500)) {
				anInt1014 = j;
				anInt1015 = k;
			}
			if (anInt1014 != j) {
				anInt1014 += (j - anInt1014) / 16;
			}
			if (anInt1015 != k) {
				anInt1015 += (k - anInt1015) / 16;
			}
			if (super.keyArray[1] == 1) {
				anInt1186 += (-24 - anInt1186) / 2;
			} else if (super.keyArray[2] == 1) {
				anInt1186 += (24 - anInt1186) / 2;
			} else {
				anInt1186 /= 2;
			}
			if (super.keyArray[3] == 1) {
				anInt1187 += (12 - anInt1187) / 2;
			} else if (super.keyArray[4] == 1) {
				anInt1187 += (-12 - anInt1187) / 2;
			} else {
				anInt1187 /= 2;
			}
			minimapAndCompassRotation = minimapAndCompassRotation + anInt1186 / 2 & 0x7ff;
			anInt1184 += anInt1187 / 2;
			if (anInt1184 < 128) {
				anInt1184 = 128;
			}
			if (anInt1184 > 383) {
				anInt1184 = 383;
			}
			int l = anInt1014 >> 7;
			int i1 = anInt1015 >> 7;
			int j1 = getEntityHeightOffset(plane, anInt1015, anInt1014);
			int k1 = 0;
			if ((l > 3) && (i1 > 3) && (l < 100) && (i1 < 100)) {
				for (int l1 = l - 4; l1 <= l + 4; l1++) {
					for (int k2 = i1 - 4; k2 <= i1 + 4; k2++) {
						int l2 = plane;
						if ((l2 < 3) && ((byteGroundArray[1][l1][k2] & 2) == 2)) {
							l2++;
						}
						int i3 = j1 - averageTileHeight[l2][l1][k2];
						if (i3 > k1) {
							k1 = i3;
						}
					}
				}
			}
			Client.anInt1005++;
			if (Client.anInt1005 > 1512) {
				Client.anInt1005 = 0;
				outputStream.putOperation(77);
				outputStream.putByte(0);
				int i2 = outputStream.offset;
				outputStream.putByte((int) (Math.random() * 256D));
				outputStream.putByte(101);
				outputStream.putByte(233);
				outputStream.putShort(45092);
				if ((int) (Math.random() * 2D) == 0) {
					outputStream.putShort(35784);
				}
				outputStream.putByte((int) (Math.random() * 256D));
				outputStream.putByte(64);
				outputStream.putByte(38);
				outputStream.putShort((int) (Math.random() * 65536D));
				outputStream.putShort((int) (Math.random() * 65536D));
				outputStream.putSizeByte(outputStream.offset - i2);
			}
			int j2 = k1 * 192;
			if (j2 > 0x17f00) {
				j2 = 0x17f00;
			}
			if (j2 < 32768) {
				j2 = 32768;
			}
			if (j2 > anInt984) {
				anInt984 += (j2 - anInt984) / 24;
				return;
			}
			if (j2 < anInt984) {
				anInt984 += (j2 - anInt984) / 80;
			}
		} catch (Exception _ex) {
			Signlink.reporterror("glfc_ex " + Client.myPlayer.x + "," + Client.myPlayer.y + ","
			+ anInt1014 + "," + anInt1015 + "," + anInt1069 + "," + anInt1070 + "," + baseX + ","
			+ baseY);
			throw new RuntimeException("eek");
		}
	}

	private void method114() {
		for (int i = -1; i < playerCount; i++) {
			int j;
			if (i == -1) {
				j = myPlayerIndex;
			} else {
				j = playerIndices[i];
			}
			Player player = playerArray[j];
			if (player != null) {
				method96(player);
			}
		}
	}

	private void method115() {
		if (loadingStage == 2) {
			for (NodeSub2 nodeSub2 = (NodeSub2) aClass19_1179.getFront(); nodeSub2 != null; nodeSub2 = (NodeSub2) aClass19_1179
			.getNext()) {
				if (nodeSub2.anInt1294 > 0) {
					nodeSub2.anInt1294--;
				}
				if (nodeSub2.anInt1294 == 0) {
					if ((nodeSub2.anInt1299 < 0)
					|| Region.method178(nodeSub2.anInt1299, nodeSub2.anInt1301)) {
						method142(nodeSub2.anInt1298, nodeSub2.anInt1295, nodeSub2.anInt1300,
						nodeSub2.anInt1301, nodeSub2.anInt1297, nodeSub2.anInt1296,
						nodeSub2.anInt1299);
						nodeSub2.unlink();
					}
				} else {
					if (nodeSub2.anInt1302 > 0) {
						nodeSub2.anInt1302--;
					}
					if ((nodeSub2.anInt1302 == 0)
					&& (nodeSub2.anInt1297 >= 1)
					&& (nodeSub2.anInt1298 >= 1)
					&& (nodeSub2.anInt1297 <= 102)
					&& (nodeSub2.anInt1298 <= 102)
					&& ((nodeSub2.anInt1291 < 0) || Region.method178(nodeSub2.anInt1291,
					nodeSub2.anInt1293))) {
						method142(nodeSub2.anInt1298, nodeSub2.anInt1295, nodeSub2.anInt1292,
						nodeSub2.anInt1293, nodeSub2.anInt1297, nodeSub2.anInt1296,
						nodeSub2.anInt1291);
						nodeSub2.anInt1302 = -1;
						if ((nodeSub2.anInt1291 == nodeSub2.anInt1299)
						&& (nodeSub2.anInt1299 == -1)) {
							nodeSub2.unlink();
						} else if ((nodeSub2.anInt1291 == nodeSub2.anInt1299)
						&& (nodeSub2.anInt1292 == nodeSub2.anInt1300)
						&& (nodeSub2.anInt1293 == nodeSub2.anInt1301)) {
							nodeSub2.unlink();
						}
					}
				}
			}
		}
	}

	private void method117(Packet buffer) {
		buffer.initBitAccess();
		int j = buffer.getBits(1);
		if (j == 0) {
			return;
		}
		int k = buffer.getBits(2);
		if (k == 0) {
			anIntArray894[anInt893++] = myPlayerIndex;
			return;
		}
		if (k == 1) {
			int l = buffer.getBits(3);
			Client.myPlayer.moveInDir(false, l);
			int k1 = buffer.getBits(1);
			if (k1 == 1) {
				anIntArray894[anInt893++] = myPlayerIndex;
			}
			return;
		}
		if (k == 2) {
			int i1 = buffer.getBits(3);
			Client.myPlayer.moveInDir(true, i1);
			int l1 = buffer.getBits(3);
			Client.myPlayer.moveInDir(true, l1);
			int j2 = buffer.getBits(1);
			if (j2 == 1) {
				anIntArray894[anInt893++] = myPlayerIndex;
			}
			return;
		}
		if (k == 3) {
			plane = buffer.getBits(2);
			int j1 = buffer.getBits(1);
			int i2 = buffer.getBits(1);
			if (i2 == 1) {
				anIntArray894[anInt893++] = myPlayerIndex;
			}
			int k2 = buffer.getBits(7);
			int l2 = buffer.getBits(7);
			Client.myPlayer.setPos(l2, k2, j1 == 1);
		}
	}

	private boolean method119(int i, int j) {
		boolean flag1 = false;
		Interface iComponent = Interface.interfaceCache[j];
		for (int element : iComponent.children) {
			if (element == -1) {
				break;
			}
			Interface childInterface = Interface.interfaceCache[element];
			if (childInterface.type == 1) {
				flag1 |= method119(i, childInterface.id);
			}
			if ((childInterface.type == 6)
			&& ((childInterface.anInt257 != -1) || (childInterface.anInt258 != -1))) {
				boolean flag2 = interfaceIsSelected(childInterface);
				int l;
				if (flag2) {
					l = childInterface.anInt258;
				} else {
					l = childInterface.anInt257;
				}
				if (l != -1) {
					Animation animation = Animation.animations[l];
					for (childInterface.anInt208 += i; childInterface.anInt208 > animation
					.method258(childInterface.anInt246);) {
						childInterface.anInt208 -= animation.method258(childInterface.anInt246) + 1;
						childInterface.anInt246++;
						if (childInterface.anInt246 >= animation.anInt352) {
							childInterface.anInt246 -= animation.anInt356;
							if ((childInterface.anInt246 < 0)
							|| (childInterface.anInt246 >= animation.anInt352)) {
								childInterface.anInt246 = 0;
							}
						}
						flag1 = true;
					}
				}
			}
		}
		return flag1;
	}

	private int method120() {
		int j = 3;
		if (cameraPitch < 310) {
			int k = xCameraPos >> 7;
			int l = yCameraPos >> 7;
			int i1 = Client.myPlayer.x >> 7;
			int j1 = Client.myPlayer.y >> 7;
			if ((byteGroundArray[plane][k][l] & 4) != 0) {
				j = plane;
			}
			int k1;
			if (i1 > k) {
				k1 = i1 - k;
			} else {
				k1 = k - i1;
			}
			int l1;
			if (j1 > l) {
				l1 = j1 - l;
			} else {
				l1 = l - j1;
			}
			if (k1 > l1) {
				int i2 = (l1 * 0x10000) / k1;
				int k2 = 32768;
				while (k != i1) {
					if (k < i1) {
						k++;
					} else if (k > i1) {
						k--;
					}
					if ((byteGroundArray[plane][k][l] & 4) != 0) {
						j = plane;
					}
					k2 += i2;
					if (k2 >= 0x10000) {
						k2 -= 0x10000;
						if (l < j1) {
							l++;
						} else if (l > j1) {
							l--;
						}
						if ((byteGroundArray[plane][k][l] & 4) != 0) {
							j = plane;
						}
					}
				}
			} else {
				int j2 = (k1 * 0x10000) / l1;
				int l2 = 32768;
				while (l != j1) {
					if (l < j1) {
						l++;
					} else if (l > j1) {
						l--;
					}
					if ((byteGroundArray[plane][k][l] & 4) != 0) {
						j = plane;
					}
					l2 += j2;
					if (l2 >= 0x10000) {
						l2 -= 0x10000;
						if (k < i1) {
							k++;
						} else if (k > i1) {
							k--;
						}
						if ((byteGroundArray[plane][k][l] & 4) != 0) {
							j = plane;
						}
					}
				}
			}
		}
		if ((byteGroundArray[plane][Client.myPlayer.x >> 7][Client.myPlayer.y >> 7] & 4) != 0) {
			j = plane;
		}
		return j;
	}

	private int method121() {
		int j = getEntityHeightOffset(plane, yCameraPos, xCameraPos);
		if ((j - zCameraPos < 800)
		&& ((byteGroundArray[plane][xCameraPos >> 7][yCameraPos >> 7] & 4) != 0)) {
			return plane;
		} else {
			return 3;
		}
	}

	private void method130(int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2) {
		NodeSub2 nodeSub2_1 = null;
		for (NodeSub2 nodeSub2_2 = (NodeSub2) aClass19_1179.getFront(); nodeSub2_2 != null; nodeSub2_2 = (NodeSub2) aClass19_1179
		.getNext()) {
			if ((nodeSub2_2.anInt1295 != l1) || (nodeSub2_2.anInt1297 != i2)
			|| (nodeSub2_2.anInt1298 != j1) || (nodeSub2_2.anInt1296 != i1)) {
				continue;
			}
			nodeSub2_1 = nodeSub2_2;
			break;
		}
		if (nodeSub2_1 == null) {
			nodeSub2_1 = new NodeSub2();
			nodeSub2_1.anInt1295 = l1;
			nodeSub2_1.anInt1296 = i1;
			nodeSub2_1.anInt1297 = i2;
			nodeSub2_1.anInt1298 = j1;
			method89(nodeSub2_1);
			aClass19_1179.insertBack(nodeSub2_1);
		}
		nodeSub2_1.anInt1291 = k;
		nodeSub2_1.anInt1293 = k1;
		nodeSub2_1.anInt1292 = l;
		nodeSub2_1.anInt1302 = j2;
		nodeSub2_1.anInt1294 = j;
	}

	private void method134(Packet buffer) {
		int j = buffer.getBits(8);
		if (j < playerCount) {
			for (int k = j; k < playerCount; k++) {
				anIntArray840[anInt839++] = playerIndices[k];
			}
		}
		if (j > playerCount) {
			Signlink.reporterror(myUsername + " Too many players");
			throw new RuntimeException("eek");
		}
		playerCount = 0;
		for (int l = 0; l < j; l++) {
			int i1 = playerIndices[l];
			Player player = playerArray[i1];
			int j1 = buffer.getBits(1);
			if (j1 == 0) {
				playerIndices[playerCount++] = i1;
				player.anInt1537 = Client.loopCycle;
			} else {
				int k1 = buffer.getBits(2);
				if (k1 == 0) {
					playerIndices[playerCount++] = i1;
					player.anInt1537 = Client.loopCycle;
					anIntArray894[anInt893++] = i1;
				} else if (k1 == 1) {
					playerIndices[playerCount++] = i1;
					player.anInt1537 = Client.loopCycle;
					int l1 = buffer.getBits(3);
					player.moveInDir(false, l1);
					int j2 = buffer.getBits(1);
					if (j2 == 1) {
						anIntArray894[anInt893++] = i1;
					}
				} else if (k1 == 2) {
					playerIndices[playerCount++] = i1;
					player.anInt1537 = Client.loopCycle;
					int i2 = buffer.getBits(3);
					player.moveInDir(true, i2);
					int k2 = buffer.getBits(3);
					player.moveInDir(true, k2);
					int l2 = buffer.getBits(1);
					if (l2 == 1) {
						anIntArray894[anInt893++] = i1;
					}
				} else if (k1 == 3) {
					anIntArray840[anInt839++] = i1;
				}
			}
		}
	}

	private void method137(Packet buffer, int j) {
		if (j == 84) {
			int k = buffer.getUnsignedByte();
			int j3 = anInt1268 + (k >> 4 & 7);
			int i6 = anInt1269 + (k & 7);
			int l8 = buffer.getUnsignedShort();
			int k11 = buffer.getUnsignedShort();
			int l13 = buffer.getUnsignedShort();
			if ((j3 >= 0) && (i6 >= 0) && (j3 < 104) && (i6 < 104)) {
				Deque deque = groundArray[plane][j3][i6];
				if (deque != null) {
					for (Item item = (Item) deque.getFront(); item != null; item = (Item) deque
					.getNext()) {
						if ((item.ID != (l8 & 0x7fff)) || (item.anInt1559 != k11)) {
							continue;
						}
						item.anInt1559 = l13;
						break;
					}
					spawnGroundItem(j3, i6);
				}
			}
			return;
		}
		if (j == 105) {
			int l = buffer.getUnsignedByte();
			int k3 = anInt1268 + (l >> 4 & 7);
			int j6 = anInt1269 + (l & 7);
			int i9 = buffer.getUnsignedShort();
			int l11 = buffer.getUnsignedByte();
			int i14 = l11 >> 4 & 0xf;
			int i16 = l11 & 7;
			if ((Client.myPlayer.walkQueueX[0] >= k3 - i14)
			&& (Client.myPlayer.walkQueueX[0] <= k3 + i14)
			&& (Client.myPlayer.walkQueueY[0] >= j6 - i14)
			&& (Client.myPlayer.walkQueueY[0] <= j6 + i14) && aBoolean848 && !Client.lowMem
			&& (anInt1062 < 50)) {
				anIntArray1207[anInt1062] = i9;
				anIntArray1241[anInt1062] = i16;
				anIntArray1250[anInt1062] = Sounds.anIntArray326[i9];
				anInt1062++;
			}
		}
		if (j == 215) {
			int i1 = buffer.getUnsignedLEShortA();
			int l3 = buffer.getUnsignedByteS();
			int k6 = anInt1268 + (l3 >> 4 & 7);
			int j9 = anInt1269 + (l3 & 7);
			int i12 = buffer.getUnsignedLEShortA();
			int j14 = buffer.getUnsignedShort();
			if ((k6 >= 0) && (j9 >= 0) && (k6 < 104) && (j9 < 104) && (i12 != unknownInt10)) {
				Item item = new Item();
				item.ID = i1;
				item.anInt1559 = j14;
				if (groundArray[plane][k6][j9] == null) {
					groundArray[plane][k6][j9] = new Deque();
				}
				groundArray[plane][k6][j9].insertBack(item);
				spawnGroundItem(k6, j9);
			}
			return;
		}
		if (j == 156) {
			int j1 = buffer.getUnsignedByteA();
			int i4 = anInt1268 + (j1 >> 4 & 7);
			int l6 = anInt1269 + (j1 & 7);
			int k9 = buffer.getUnsignedShort();
			if ((i4 >= 0) && (l6 >= 0) && (i4 < 104) && (l6 < 104)) {
				Deque class19 = groundArray[plane][i4][l6];
				if (class19 != null) {
					for (Item item = (Item) class19.getFront(); item != null; item = (Item) class19
					.getNext()) {
						if (item.ID != (k9 & 0x7fff)) {
							continue;
						}
						item.unlink();
						break;
					}
					if (class19.getFront() == null) {
						groundArray[plane][i4][l6] = null;
					}
					spawnGroundItem(i4, l6);
				}
			}
			return;
		}
		if (j == 160) {
			int k1 = buffer.getUnsignedByteS();
			int j4 = anInt1268 + (k1 >> 4 & 7);
			int i7 = anInt1269 + (k1 & 7);
			int l9 = buffer.getUnsignedByteS();
			int j12 = l9 >> 2;
			int k14 = l9 & 3;
			int j16 = anIntArray1177[j12];
			int j17 = buffer.getUnsignedLEShortA();
			if ((j4 >= 0) && (i7 >= 0) && (j4 < 103) && (i7 < 103)) {
				int j18 = averageTileHeight[plane][j4][i7];
				int i19 = averageTileHeight[plane][j4 + 1][i7];
				int l19 = averageTileHeight[plane][j4 + 1][i7 + 1];
				int k20 = averageTileHeight[plane][j4][i7 + 1];
				if (j16 == 0) {
					WallObject wallObject = sceneGraph.method296(plane, j4, i7);
					if (wallObject != null) {
						int k21 = wallObject.uid >> 14 & 0x7fff;
						if (j12 == 2) {
							wallObject.aClass30_Sub2_Sub4_278 = new AnimatedObject(k21, 4 + k14, 2,
							i19, l19, j18, k20, j17, false);
							wallObject.aClass30_Sub2_Sub4_279 = new AnimatedObject(k21,
							k14 + 1 & 3, 2, i19, l19, j18, k20, j17, false);
						} else {
							wallObject.aClass30_Sub2_Sub4_278 = new AnimatedObject(k21, k14, j12,
							i19, l19, j18, k20, j17, false);
						}
					}
				}
				if (j16 == 1) {
					WallDecoration wallDecoration = sceneGraph.method297(j4, i7, plane);
					if (wallDecoration != null) {
						wallDecoration.animation = new AnimatedObject(
						wallDecoration.uid >> 14 & 0x7fff, 0, 4, i19, l19, j18, k20, j17, false);
					}
				}
				if (j16 == 2) {
					InteractiveObject interactiveObject = sceneGraph.method298(j4, i7, plane);
					if (j12 == 11) {
						j12 = 10;
					}
					if (interactiveObject != null) {
						interactiveObject.animation = new AnimatedObject(
						interactiveObject.uid >> 14 & 0x7fff, k14, j12, i19, l19, j18, k20, j17,
						false);
					}
				}
				if (j16 == 3) {
					GroundDecoration groundDecoration = sceneGraph.method299(i7, j4, plane);
					if (groundDecoration != null) {
						groundDecoration.animation = new AnimatedObject(
						groundDecoration.uid >> 14 & 0x7fff, k14, 22, i19, l19, j18, k20, j17,
						false);
					}
				}
			}
			return;
		}
		if (j == 147) {
			int l1 = buffer.getUnsignedByteS();
			int k4 = anInt1268 + (l1 >> 4 & 7);
			int j7 = anInt1269 + (l1 & 7);
			int i10 = buffer.getUnsignedShort();
			byte byte0 = buffer.getByteS();
			int l14 = buffer.getUnsignedLEShort();
			byte byte1 = buffer.getByteC();
			int k17 = buffer.getUnsignedShort();
			int k18 = buffer.getUnsignedByteS();
			int j19 = k18 >> 2;
			int i20 = k18 & 3;
			int l20 = anIntArray1177[j19];
			byte byte2 = buffer.getByte();
			int l21 = buffer.getUnsignedShort();
			byte byte3 = buffer.getByteC();
			Player player;
			if (i10 == unknownInt10) {
				player = Client.myPlayer;
			} else {
				player = playerArray[i10];
			}
			if (player != null) {
				ObjectDefinition objectDefinition = ObjectDefinition.forID(l21);
				int i22 = averageTileHeight[plane][k4][j7];
				int j22 = averageTileHeight[plane][k4 + 1][j7];
				int k22 = averageTileHeight[plane][k4 + 1][j7 + 1];
				int l22 = averageTileHeight[plane][k4][j7 + 1];
				Model model = objectDefinition.method578(j19, i20, i22, j22, k22, l22,
				-1);
				if (model != null) {
					method130(k17 + 1, -1, 0, l20, j7, 0, plane, k4, l14 + 1);
					player.anInt1707 = l14 + Client.loopCycle;
					player.anInt1708 = k17 + Client.loopCycle;
					player.aModel_1714 = model;
					int i23 = objectDefinition.anInt744;
					int j23 = objectDefinition.anInt761;
					if ((i20 == 1) || (i20 == 3)) {
						i23 = objectDefinition.anInt761;
						j23 = objectDefinition.anInt744;
					}
					player.anInt1711 = k4 * 128 + i23 * 64;
					player.anInt1713 = j7 * 128 + j23 * 64;
					player.anInt1712 = getEntityHeightOffset(plane, player.anInt1713,
					player.anInt1711);
					if (byte2 > byte0) {
						byte byte4 = byte2;
						byte2 = byte0;
						byte0 = byte4;
					}
					if (byte3 > byte1) {
						byte byte5 = byte3;
						byte3 = byte1;
						byte1 = byte5;
					}
					player.anInt1719 = k4 + byte2;
					player.anInt1721 = k4 + byte0;
					player.anInt1720 = j7 + byte3;
					player.anInt1722 = j7 + byte1;
				}
			}
		}
		if (j == 151) {
			int i2 = buffer.getUnsignedByteA();
			int l4 = anInt1268 + (i2 >> 4 & 7);
			int k7 = anInt1269 + (i2 & 7);
			int j10 = buffer.getUnsignedLEShort();
			int k12 = buffer.getUnsignedByteS();
			int i15 = k12 >> 2;
			int k16 = k12 & 3;
			int l17 = anIntArray1177[i15];
			if ((l4 >= 0) && (k7 >= 0) && (l4 < 104) && (k7 < 104)) {
				method130(-1, j10, k16, l17, k7, i15, plane, l4, 0);
			}
			return;
		}
		if (j == 4) {
			int j2 = buffer.getUnsignedByte();
			int i5 = anInt1268 + (j2 >> 4 & 7);
			int l7 = anInt1269 + (j2 & 7);
			int k10 = buffer.getUnsignedShort();
			int l12 = buffer.getUnsignedByte();
			int j15 = buffer.getUnsignedShort();
			if ((i5 >= 0) && (l7 >= 0) && (i5 < 104) && (l7 < 104)) {
				i5 = i5 * 128 + 64;
				l7 = l7 * 128 + 64;
				StillGraphic stillGraphic = new StillGraphic(plane, Client.loopCycle, j15, k10,
				getEntityHeightOffset(plane, l7, i5) - l12, l7, i5);
				stillGraphicList.insertBack(stillGraphic);
			}
			return;
		}
		if (j == 44) {
			int k2 = buffer.getUnsignedShortA();
			int j5 = buffer.getUnsignedShort();
			int i8 = buffer.getUnsignedByte();
			int l10 = anInt1268 + (i8 >> 4 & 7);
			int i13 = anInt1269 + (i8 & 7);
			if ((l10 >= 0) && (i13 >= 0) && (l10 < 104) && (i13 < 104)) {
				Item item = new Item();
				item.ID = k2;
				item.anInt1559 = j5;
				if (groundArray[plane][l10][i13] == null) {
					groundArray[plane][l10][i13] = new Deque();
				}
				groundArray[plane][l10][i13].insertBack(item);
				spawnGroundItem(l10, i13);
			}
			return;
		}
		if (j == 101) {
			int l2 = buffer.getUnsignedByteC();
			int k5 = l2 >> 2;
			int j8 = l2 & 3;
			int i11 = anIntArray1177[k5];
			int j13 = buffer.getUnsignedByte();
			int k15 = anInt1268 + (j13 >> 4 & 7);
			int l16 = anInt1269 + (j13 & 7);
			if ((k15 >= 0) && (l16 >= 0) && (k15 < 104) && (l16 < 104)) {
				method130(-1, -1, j8, i11, l16, k5, plane, k15, 0);
			}
			return;
		}
		if (j == 117) {
			int i3 = buffer.getUnsignedByte();
			int l5 = anInt1268 + (i3 >> 4 & 7);
			int k8 = anInt1269 + (i3 & 7);
			int j11 = l5 + buffer.getByte();
			int k13 = k8 + buffer.getByte();
			int l15 = buffer.getShort();
			int i17 = buffer.getUnsignedShort();
			int i18 = buffer.getUnsignedByte() * 4;
			int l18 = buffer.getUnsignedByte() * 4;
			int k19 = buffer.getUnsignedShort();
			int j20 = buffer.getUnsignedShort();
			int i21 = buffer.getUnsignedByte();
			int j21 = buffer.getUnsignedByte();
			if ((l5 >= 0) && (k8 >= 0) && (l5 < 104) && (k8 < 104) && (j11 >= 0) && (k13 >= 0)
			&& (j11 < 104) && (k13 < 104) && (i17 != 65535)) {
				l5 = l5 * 128 + 64;
				k8 = k8 * 128 + 64;
				j11 = j11 * 128 + 64;
				k13 = k13 * 128 + 64;
				Projectile projectile = new Projectile(i21, l18, k19 + Client.loopCycle, j20
				+ Client.loopCycle, j21, plane, getEntityHeightOffset(plane, k8, l5) - i18, k8, l5,
				l15, i17);
				projectile.getProjectileHeight(k19 + Client.loopCycle, k13, getEntityHeightOffset(
				plane, k13, j11)
				- l18, j11);
				projectileList.insertBack(projectile);
			}
		}
	}

	private void method139(Packet buffer) {
		buffer.initBitAccess();
		int k = buffer.getBits(8);
		if (k < npcCount) {
			for (int l = k; l < npcCount; l++) {
				anIntArray840[anInt839++] = npcIndices[l];
			}
		}
		if (k > npcCount) {
			Signlink.reporterror(myUsername + " Too many npcs");
			throw new RuntimeException("eek");
		}
		npcCount = 0;
		for (int i1 = 0; i1 < k; i1++) {
			int j1 = npcIndices[i1];
			Npc npc = npcArray[j1];
			int k1 = buffer.getBits(1);
			if (k1 == 0) {
				npcIndices[npcCount++] = j1;
				npc.anInt1537 = Client.loopCycle;
			} else {
				int l1 = buffer.getBits(2);
				if (l1 == 0) {
					npcIndices[npcCount++] = j1;
					npc.anInt1537 = Client.loopCycle;
					anIntArray894[anInt893++] = j1;
				} else if (l1 == 1) {
					npcIndices[npcCount++] = j1;
					npc.anInt1537 = Client.loopCycle;
					int i2 = buffer.getBits(3);
					npc.moveInDir(false, i2);
					int k2 = buffer.getBits(1);
					if (k2 == 1) {
						anIntArray894[anInt893++] = j1;
					}
				} else if (l1 == 2) {
					npcIndices[npcCount++] = j1;
					npc.anInt1537 = Client.loopCycle;
					int j2 = buffer.getBits(3);
					npc.moveInDir(true, j2);
					int l2 = buffer.getBits(3);
					npc.moveInDir(true, l2);
					int i3 = buffer.getBits(1);
					if (i3 == 1) {
						anIntArray894[anInt893++] = j1;
					}
				} else if (l1 == 3) {
					anIntArray840[anInt839++] = j1;
				}
			}
		}
	}

	private void method142(int i, int j, int k, int l, int i1, int j1, int k1) {
		if ((i1 >= 1) && (i >= 1) && (i1 <= 102) && (i <= 102)) {
			if (Client.lowMem && (j != plane)) {
				return;
			}
			int i2 = 0;
			if (j1 == 0) {
				i2 = sceneGraph.method300(j, i1, i);
			}
			if (j1 == 1) {
				i2 = sceneGraph.method301(j, i1, i);
			}
			if (j1 == 2) {
				i2 = sceneGraph.method302(j, i1, i);
			}
			if (j1 == 3) {
				i2 = sceneGraph.method303(j, i1, i);
			}
			if (i2 != 0) {
				int i3 = sceneGraph.method304(j, i1, i, i2);
				int j2 = i2 >> 14 & 0x7fff;
				int k2 = i3 & 0x1f;
				int l2 = i3 >> 6;
				if (j1 == 0) {
					sceneGraph.method291(i1, j, i, (byte) -119);
					ObjectDefinition class46 = ObjectDefinition.forID(j2);
					if (class46.aBoolean767) {
						collisionMap[j].method215(l2, k2, class46.aBoolean757, i1, i);
					}
				}
				if (j1 == 1) {
					sceneGraph.method292(i, j, i1);
				}
				if (j1 == 2) {
					sceneGraph.method293(j, i1, i);
					ObjectDefinition class46_1 = ObjectDefinition.forID(j2);
					if ((i1 + class46_1.anInt744 > 103) || (i + class46_1.anInt744 > 103)
					|| (i1 + class46_1.anInt761 > 103) || (i + class46_1.anInt761 > 103)) {
						return;
					}
					if (class46_1.aBoolean767) {
						collisionMap[j].method216(l2, class46_1.anInt744, i1, i,
						class46_1.anInt761, class46_1.aBoolean757);
					}
				}
				if (j1 == 3) {
					sceneGraph.method294(j, i, i1);
					ObjectDefinition class46_2 = ObjectDefinition.forID(j2);
					if (class46_2.aBoolean767 && class46_2.hasActions) {
						collisionMap[j].method218(i1, i);
					}
				}
			}
			if (k1 >= 0) {
				int j3 = j;
				if ((j3 < 3) && ((byteGroundArray[1][i1][i] & 2) == 2)) {
					j3++;
				}
				Region.method188(sceneGraph, k, i, l, j3, collisionMap[j], averageTileHeight, i1, k1,
				j);
			}
		}
	}

	private void method146() {
		anInt1265++;
		renderPlayers(true);
		renderNPCs(true);
		renderPlayers(false);
		renderNPCs(false);
		renderProjectiles();
		renderStillGraphics();
		if (!aBoolean1160) {
			int i = anInt1184;
			if (anInt984 / 256 > i) {
				i = anInt984 / 256;
			}
			if (aBooleanArray876[4] && (anIntArray1203[4] + 128 > i)) {
				i = anIntArray1203[4] + 128;
			}
			int k = minimapAndCompassRotation + anInt896 & 0x7ff;
			setCameraPos(600 + i * 3, i, anInt1014, getEntityHeightOffset(plane, Client.myPlayer.y,
			Client.myPlayer.x) - 50, k, anInt1015);
		}
		int j;
		if (!aBoolean1160) {
			j = method120();
		} else {
			j = method121();
		}
		int l = xCameraPos;
		int i1 = zCameraPos;
		int j1 = yCameraPos;
		int k1 = cameraPitch;
		int l1 = cameraYaw;
		for (int i2 = 0; i2 < 5; i2++) {
			if (aBooleanArray876[i2]) {
				int j2 = (int) ((Math.random() * (anIntArray873[i2] * 2 + 1) - anIntArray873[i2]) + Math
				.sin(anIntArray1030[i2] * (anIntArray928[i2] / 100D))
				* anIntArray1203[i2]);
				if (i2 == 0) {
					xCameraPos += j2;
				}
				if (i2 == 1) {
					zCameraPos += j2;
				}
				if (i2 == 2) {
					yCameraPos += j2;
				}
				if (i2 == 3) {
					cameraYaw = cameraYaw + j2 & 0x7ff;
				}
				if (i2 == 4) {
					cameraPitch += j2;
					if (cameraPitch < 128) {
						cameraPitch = 128;
					}
					if (cameraPitch > 383) {
						cameraPitch = 383;
					}
				}
			}
		}
		int k2 = Renderer3D.priority;
		Model.aBoolean1684 = true;
		Model.anInt1687 = 0;
		Model.anInt1685 = super.mouseX - 4;
		Model.anInt1686 = super.mouseY - 4;
		Renderer2D.clearPixels();
		sceneGraph.method313(xCameraPos, yCameraPos, cameraYaw, zCameraPos, j, cameraPitch);
		sceneGraph.clearObjectActions();
		updateEntities();
		drawHeadIcon();
		loadTextures(k2);
		draw3dScreen();
		gameScreenCanvas.drawGraphics(super.graphics, 4, 4);
		xCameraPos = l;
		zCameraPos = i1;
		yCameraPos = j1;
		cameraPitch = k1;
		cameraYaw = l1;
	}

	private void method22() {
		try {
			anInt985 = -1;
			stillGraphicList.clear();
			projectileList.clear();
			Renderer3D.clearTextures();
			unlinkMRUNodes();
			sceneGraph.initToNull();
			System.gc();
			for (int i = 0; i < 4; i++) {
				collisionMap[i].reset();
			}
			for (int l = 0; l < 4; l++) {
				for (int k1 = 0; k1 < 104; k1++) {
					for (int j2 = 0; j2 < 104; j2++) {
						byteGroundArray[l][k1][j2] = 0;
					}
				}
			}
			Region region = new Region(byteGroundArray, averageTileHeight);
			int k2 = aByteArrayArray1183.length;
			outputStream.putOperation(0);
			if (!aBoolean1159) {
				for (int i3 = 0; i3 < k2; i3++) {
					int i4 = (anIntArray1234[i3] >> 8) * 64 - baseX;
					int k5 = (anIntArray1234[i3] & 0xff) * 64 - baseY;
					byte abyte0[] = aByteArrayArray1183[i3];
					if (abyte0 != null) {
						region.method180(abyte0, k5, i4, (anInt1069 - 6) * 8, (anInt1070 - 6) * 8,
						collisionMap);
					}
				}
				for (int j4 = 0; j4 < k2; j4++) {
					int l5 = (anIntArray1234[j4] >> 8) * 64 - baseX;
					int k7 = (anIntArray1234[j4] & 0xff) * 64 - baseY;
					byte abyte2[] = aByteArrayArray1183[j4];
					if ((abyte2 == null) && (anInt1070 < 800)) {
						region.method174(k7, 64, 64, l5);
					}
				}
				Client.anInt1097++;
				if (Client.anInt1097 > 160) {
					Client.anInt1097 = 0;
					outputStream.putOperation(238);
					outputStream.putByte(96);
				}
				outputStream.putOperation(0);
				for (int i6 = 0; i6 < k2; i6++) {
					byte abyte1[] = aByteArrayArray1247[i6];
					if (abyte1 != null) {
						int l8 = (anIntArray1234[i6] >> 8) * 64 - baseX;
						int k9 = (anIntArray1234[i6] & 0xff) * 64 - baseY;
						region.method190(l8, collisionMap, k9, sceneGraph, abyte1);
					}
				}
			}
			if (aBoolean1159) {
				for (int j3 = 0; j3 < 4; j3++) {
					for (int k4 = 0; k4 < 13; k4++) {
						for (int j6 = 0; j6 < 13; j6++) {
							int l7 = anIntArrayArrayArray1129[j3][k4][j6];
							if (l7 != -1) {
								int i9 = l7 >> 24 & 3;
								int l9 = l7 >> 1 & 3;
								int j10 = l7 >> 14 & 0x3ff;
								int l10 = l7 >> 3 & 0x7ff;
								int j11 = (j10 / 8 << 8) + l10 / 8;
								for (int l11 = 0; l11 < anIntArray1234.length; l11++) {
									if ((anIntArray1234[l11] != j11)
									|| (aByteArrayArray1183[l11] == null)) {
										continue;
									}
									region.method179(i9, l9, collisionMap, k4 * 8, (j10 & 7) * 8,
									aByteArrayArray1183[l11], (l10 & 7) * 8, j3, j6 * 8);
									break;
								}
							}
						}
					}
				}
				for (int l4 = 0; l4 < 13; l4++) {
					for (int k6 = 0; k6 < 13; k6++) {
						int i8 = anIntArrayArrayArray1129[0][l4][k6];
						if (i8 == -1) {
							region.method174(k6 * 8, 8, 8, l4 * 8);
						}
					}
				}
				outputStream.putOperation(0);
				for (int l6 = 0; l6 < 4; l6++) {
					for (int j8 = 0; j8 < 13; j8++) {
						for (int j9 = 0; j9 < 13; j9++) {
							int i10 = anIntArrayArrayArray1129[l6][j8][j9];
							if (i10 != -1) {
								int k10 = i10 >> 24 & 3;
								int i11 = i10 >> 1 & 3;
								int k11 = i10 >> 14 & 0x3ff;
								int i12 = i10 >> 3 & 0x7ff;
								int j12 = (k11 / 8 << 8) + i12 / 8;
								for (int k12 = 0; k12 < anIntArray1234.length; k12++) {
									if ((anIntArray1234[k12] != j12)
									|| (aByteArrayArray1247[k12] == null)) {
										continue;
									}
									region.method183(collisionMap, sceneGraph, k10, j8 * 8,
									(i12 & 7) * 8, l6, aByteArrayArray1247[k12], (k11 & 7) * 8,
									i11, j9 * 8);
									break;
								}
							}
						}
					}
				}
			}
			outputStream.putOperation(0);
			region.method171(collisionMap, sceneGraph);
			gameScreenCanvas.init();
			outputStream.putOperation(0);
			int k3 = Region.anInt145;
			if (k3 > plane) {
				k3 = plane;
			}
			if (k3 < plane - 1) {
				k3 = plane - 1;
			}
			if (Client.lowMem) {
				sceneGraph.method275(Region.anInt145);
			} else {
				sceneGraph.method275(0);
			}
			for (int i5 = 0; i5 < 104; i5++) {
				for (int i7 = 0; i7 < 104; i7++) {
					spawnGroundItem(i5, i7);
				}
			}
			Client.anInt1051++;
			if (Client.anInt1051 > 98) {
				Client.anInt1051 = 0;
				outputStream.putOperation(150);
			}
			method63();
		} catch (Exception exception) {
		}
		ObjectDefinition.mruNodes1.clear();
		if (super.frame != null) {
			outputStream.putOperation(210);
			outputStream.putInt(0x3f008edd);
		}
		if (Client.lowMem && (Signlink.cache_dat != null)) {
			int j = onDemandFetcher.getVersionCount(0);
			for (int i1 = 0; i1 < j; i1++) {
				int l1 = onDemandFetcher.getModelIndex(i1);
				if ((l1 & 0x79) == 0) {
					Model.method461(i1);
				}
			}
		}
		System.gc();
		Renderer3D.resetTextures();
		onDemandFetcher.method566();
		int k = (anInt1069 - 6) / 8 - 1;
		int j1 = (anInt1069 + 6) / 8 + 1;
		int i2 = (anInt1070 - 6) / 8 - 1;
		int l2 = (anInt1070 + 6) / 8 + 1;
		if (aBoolean1141) {
			k = 49;
			j1 = 50;
			i2 = 49;
			l2 = 50;
		}
		for (int l3 = k; l3 <= j1; l3++) {
			for (int j5 = i2; j5 <= l2; j5++) {
				if ((l3 == k) || (l3 == j1) || (j5 == i2) || (j5 == l2)) {
					int j7 = onDemandFetcher.method562(0, j5, l3);
					if (j7 != -1) {
						onDemandFetcher.method560(j7, 3);
					}
					int k8 = onDemandFetcher.method562(1, j5, l3);
					if (k8 != -1) {
						onDemandFetcher.method560(k8, 3);
					}
				}
			}
		}
	}

	private void method24(int i) {
		int pixels[] = miniMap.pixels;
		int j = pixels.length;
		for (int k = 0; k < j; k++) {
			pixels[k] = 0;
		}
		for (int l = 1; l < 103; l++) {
			int i1 = 24628 + (103 - l) * 512 * 4;
			for (int k1 = 1; k1 < 103; k1++) {
				if ((byteGroundArray[i][k1][l] & 0x18) == 0) {
					sceneGraph.method309(pixels, i1, i, k1, l);
				}
				if ((i < 3) && ((byteGroundArray[i + 1][k1][l] & 8) != 0)) {
					sceneGraph.method309(pixels, i1, i + 1, k1, l);
				}
				i1 += 4;
			}
		}
		int j1 = ((238 + (int) (Math.random() * 20D)) - 10 << 16)
		+ ((238 + (int) (Math.random() * 20D)) - 10 << 8)
		+ ((238 + (int) (Math.random() * 20D)) - 10);
		int l1 = (238 + (int) (Math.random() * 20D)) - 10 << 16;
		miniMap.init();
		for (int i2 = 1; i2 < 103; i2++) {
			for (int j2 = 1; j2 < 103; j2++) {
				if ((byteGroundArray[i][j2][i2] & 0x18) == 0) {
					method50(i2, j1, j2, l1, i);
				}
				if ((i < 3) && ((byteGroundArray[i + 1][j2][i2] & 8) != 0)) {
					method50(i2, j1, j2, l1, i + 1);
				}
			}
		}
		gameScreenCanvas.init();
		anInt1071 = 0;
		for (int k2 = 0; k2 < 104; k2++) {
			for (int l2 = 0; l2 < 104; l2++) {
				int i3 = sceneGraph.method303(plane, k2, l2);
				if (i3 != 0) {
					i3 = i3 >> 14 & 0x7fff;
					int j3 = ObjectDefinition.forID(i3).anInt746;
					if (j3 >= 0) {
						int k3 = k2;
						int l3 = l2;
						if ((j3 != 22) && (j3 != 29) && (j3 != 34) && (j3 != 36) && (j3 != 46)
						&& (j3 != 47) && (j3 != 48)) {
							byte byte0 = 104;
							byte byte1 = 104;
							int ai1[][] = collisionMap[plane].collisionFlags;
							for (int i4 = 0; i4 < 10; i4++) {
								int j4 = (int) (Math.random() * 4D);
								if ((j4 == 0) && (k3 > 0) && (k3 > k2 - 3)
								&& ((ai1[k3 - 1][l3] & 0x1280108) == 0)) {
									k3--;
								}
								if ((j4 == 1) && (k3 < byte0 - 1) && (k3 < k2 + 3)
								&& ((ai1[k3 + 1][l3] & 0x1280180) == 0)) {
									k3++;
								}
								if ((j4 == 2) && (l3 > 0) && (l3 > l2 - 3)
								&& ((ai1[k3][l3 - 1] & 0x1280102) == 0)) {
									l3--;
								}
								if ((j4 == 3) && (l3 < byte1 - 1) && (l3 < l2 + 3)
								&& ((ai1[k3][l3 + 1] & 0x1280120) == 0)) {
									l3++;
								}
							}
						}
						aClass30_Sub2_Sub1_Sub1Array1140[anInt1071] = mapFunctions[j3];
						anIntArray1072[anInt1071] = k3;
						anIntArray1073[anInt1071] = l3;
						anInt1071++;
					}
				}
			}
		}
	}

	private void renderNPCs(boolean flag) {
		for (int j = 0; j < npcCount; j++) {
			Npc npc = npcArray[npcIndices[j]];
			int k = 0x20000000 + (npcIndices[j] << 14);
			if ((npc == null) || !npc.isVisible() || (npc.desc.aBoolean93 != flag)) {
				continue;
			}
			int l = npc.x >> 7;
			int i1 = npc.y >> 7;
			if ((l < 0) || (l >= 104) || (i1 < 0) || (i1 >= 104)) {
				continue;
			}
			if ((npc.boundingCube == 1) && ((npc.x & 0x7f) == 64) && ((npc.y & 0x7f) == 64)) {
				if (anIntArrayArray929[l][i1] == anInt1265) {
					continue;
				}
				anIntArrayArray929[l][i1] = anInt1265;
			}
			if (!npc.desc.aBoolean84) {
				k += 0x80000000;
			}
			sceneGraph.method285(plane, npc.anInt1552, getEntityHeightOffset(plane, npc.y, npc.x),
			k, npc.y, (npc.boundingCube - 1) * 64 + 60, npc.x, npc, npc.aBoolean1541);
		}
	}

	private void processClientOptions(int id) {
		int config = Varp.cache[id].anInt709;
		if (config == 0) {
			return;
		}
		int optionsID = variousSettings[id];
		if (config == 1) {
			if (optionsID == 1) {
				Renderer3D.setPallete(0.90000000000000002D);
			}
			if (optionsID == 2) {
				Renderer3D.setPallete(0.80000000000000004D);
			}
			if (optionsID == 3) {
				Renderer3D.setPallete(0.69999999999999996D);
			}
			if (optionsID == 4) {
				Renderer3D.setPallete(0.59999999999999998D);
			}
			ItemDefinition.spriteCache.clear();
			welcomeScreenRaised = true;
		}
		if (config == 3) {
			boolean flag1 = musicEnabled;
			if (optionsID == 0) {
				adjustVolume(musicEnabled, 0);
				musicEnabled = true;
			}
			if (optionsID == 1) {
				adjustVolume(musicEnabled, -400);
				musicEnabled = true;
			}
			if (optionsID == 2) {
				adjustVolume(musicEnabled, -800);
				musicEnabled = true;
			}
			if (optionsID == 3) {
				adjustVolume(musicEnabled, -1200);
				musicEnabled = true;
			}
			if (optionsID == 4) {
				musicEnabled = false;
			}
			if ((musicEnabled != flag1) && !Client.lowMem) {
				if (musicEnabled) {
					nextSong = currentSong;
					songChanging = true;
					onDemandFetcher.method558(2, nextSong);
				} else {
					stopMidi();
				}
				prevSong = 0;
			}
		}
		if (config == 4) {
			if (optionsID == 0) {
				aBoolean848 = true;
				setWaveVolume(0);
			}
			if (optionsID == 1) {
				aBoolean848 = true;
				setWaveVolume(-400);
			}
			if (optionsID == 2) {
				aBoolean848 = true;
				setWaveVolume(-800);
			}
			if (optionsID == 3) {
				aBoolean848 = true;
				setWaveVolume(-1200);
			}
			if (optionsID == 4) {
				aBoolean848 = false;
			}
		}
		if (config == 5) {
			anInt1253 = optionsID;
		}
		if (config == 6) {
			anInt1249 = optionsID;
		}
		if (config == 7) {
			if (interfaceIsSelected(Interface.interfaceCache[153]) == true) {
				isRunning = true;
			} else if (interfaceIsSelected(Interface.interfaceCache[152]) == true) {
				isRunning = false;
			}
		}
		if (config == 8) {
			splitPrivateChat = optionsID;
			Client.inputTaken = true;
		}
		if (config == 9) {
			anInt913 = optionsID;
		}
	}

	/**
	 * method37(int j)
	 * Loads the specified texture.
	 * 
	 * @param id
	 *            The texture to load.
	 */
	private void loadTextures(int id) {
		if (!Client.lowMem) {
			if (Renderer3D.texturePriorities[17] >= id) {
				IndexedSprite texture = Renderer3D.textures[17];
				int k = texture.width * texture.height - 1;
				int j1 = texture.width * anInt945 * 2;
				byte pixels[] = texture.pixels;
				byte abyte3[] = destTexture;
				for (int i2 = 0; i2 <= k; i2++) {
					abyte3[i2] = pixels[i2 - j1 & k];
				}
				texture.pixels = abyte3;
				destTexture = pixels;
				Renderer3D.loadTexture(17);
				Client.anInt854++;
				if (Client.anInt854 > 1235) {
					Client.anInt854 = 0;
					outputStream.putOperation(226);
					outputStream.putByte(0);
					int l2 = outputStream.offset;
					outputStream.putShort(58722);
					outputStream.putByte(240);
					outputStream.putShort((int) (Math.random() * 65536D));
					outputStream.putByte((int) (Math.random() * 256D));
					if ((int) (Math.random() * 2D) == 0) {
						outputStream.putShort(51825);
					}
					outputStream.putByte((int) (Math.random() * 256D));
					outputStream.putShort((int) (Math.random() * 65536D));
					outputStream.putShort(7130);
					outputStream.putShort((int) (Math.random() * 65536D));
					outputStream.putShort(61657);
					outputStream.putSizeByte(outputStream.offset - l2);
				}
			}
			if (Renderer3D.texturePriorities[24] >= id) {
				IndexedSprite water_texture = Renderer3D.textures[24];
				int l = water_texture.width * water_texture.height - 1;
				int k1 = water_texture.width * anInt945;
				byte pixels[] = water_texture.pixels;
				byte abyte4[] = destTexture;
				for (int j2 = 0; j2 <= l; j2++) {
					abyte4[j2] = pixels[j2 - k1 & l];
				}
				water_texture.pixels = abyte4;
				destTexture = pixels;
				Renderer3D.loadTexture(24);
			}
			if (Renderer3D.texturePriorities[40] >= id) {
				IndexedSprite lava_texture = Renderer3D.textures[40];
				int i1 = lava_texture.width * lava_texture.height - 1;
				int l1 = lava_texture.width * anInt945;
				byte pixels[] = lava_texture.pixels;
				byte abyte5[] = destTexture;
				for (int k2 = 0; k2 <= i1; k2++) {
					abyte5[k2] = pixels[k2 - l1 & i1];
				}
				lava_texture.pixels = abyte5;
				destTexture = pixels;
				Renderer3D.loadTexture(40);
			}
		}
	}

	private void method38() {
		for (int i = -1; i < playerCount; i++) {
			int j;
			if (i == -1) {
				j = myPlayerIndex;
			} else {
				j = playerIndices[i];
			}
			Player player = playerArray[j];
			if ((player != null) && (player.textCycle > 0)) {
				player.textCycle--;
				if (player.textCycle == 0) {
					player.textSpoken = null;
				}
			}
		}
		for (int k = 0; k < npcCount; k++) {
			int l = npcIndices[k];
			Npc npc = npcArray[l];
			if ((npc != null) && (npc.textCycle > 0)) {
				npc.textCycle--;
				if (npc.textCycle == 0) {
					npc.textSpoken = null;
				}
			}
		}
	}

	/**
	 * Changes the entity's height if they are on elevated ground, i.e. hills.
	 * 
	 * @return
	 *         The average of top & bottom row.
	 */
	private int getEntityHeightOffset(int plane, int y, int x) {
		int tileX = x >> 7;
		int i1 = y >> 7;
		if ((tileX < 0) || (i1 < 0) || (tileX > 103) || (i1 > 103)) {
			return 0;
		}
		if ((plane < 3) && ((byteGroundArray[1][tileX][i1] & 2) == 2)) {
			plane++;
		}
		int scaleX = x & 0x7f;
		int scaleY = y & 0x7f;
		int averageTop = averageTileHeight[plane][tileX][i1] * (128 - scaleX)
		+ averageTileHeight[plane][tileX + 1][i1] * scaleX >> 7;
		int averageBottom = averageTileHeight[plane][tileX][i1 + 1] * (128 - scaleX)
		+ averageTileHeight[plane][tileX + 1][i1 + 1] * scaleX >> 7;
		return averageTop * (128 - scaleY) + averageBottom * scaleY >> 7;
	}

	private void method45() {
		aBoolean1031 = true;
		for (int j = 0; j < 7; j++) {
			anIntArray1065[j] = -1;
			for (int k = 0; k < IdentityKit.length; k++) {
				if (IdentityKit.cache[k].aBoolean662
				|| (IdentityKit.cache[k].anInt657 != j + (aBoolean1047 ? 0 : 7))) {
					continue;
				}
				anIntArray1065[j] = k;
				break;
			}
		}
	}

	private void method46(int i, Packet buffer) {
		while (buffer.bitOffset + 21 < i * 8) {
			int k = buffer.getBits(14);
			if (k == 16383) {
				break;
			}
			if (npcArray[k] == null) {
				npcArray[k] = new Npc();
			}
			Npc npc = npcArray[k];
			npcIndices[npcCount++] = k;
			npc.anInt1537 = Client.loopCycle;
			int l = buffer.getBits(5);
			if (l > 15) {
				l -= 32;
			}
			int i1 = buffer.getBits(5);
			if (i1 > 15) {
				i1 -= 32;
			}
			int j1 = buffer.getBits(1);
			npc.desc = EntityDefinition.forID(buffer.getBits(12));
			int k1 = buffer.getBits(1);
			if (k1 == 1) {
				anIntArray894[anInt893++] = k;
			}
			npc.boundingCube = npc.desc.aByte68;
			npc.anInt1504 = npc.desc.anInt79;
			npc.walkAnimation = npc.desc.walkAnim;
			npc.anInt1555 = npc.desc.anInt58;
			npc.anInt1556 = npc.desc.anInt83;
			npc.anInt1557 = npc.desc.anInt55;
			npc.idleAnimation = npc.desc.standAnim;
			npc.setPos(Client.myPlayer.walkQueueX[0] + i1, Client.myPlayer.walkQueueY[0] + l,
			j1 == 1);
		}
		buffer.finishBitAccess();
	}

	private void renderPlayers(boolean first) {
		if ((Client.myPlayer.x >> 7 == destX) && (Client.myPlayer.y >> 7 == destY)) {
			destX = 0;
		}
		int playerCount = this.playerCount;
		if (first) {
			playerCount = 1;
		}
		for (int l = 0; l < playerCount; l++) {
			Player player;
			int i1;
			if (first) {
				player = Client.myPlayer;
				i1 = myPlayerIndex << 14;
			} else {
				player = playerArray[playerIndices[l]];
				i1 = playerIndices[l] << 14;
			}
			if ((player == null) || !player.isVisible()) {
				continue;
			}
			player.aBoolean1699 = ((Client.lowMem && (this.playerCount > 50)) || (this.playerCount > 200))
			&& !first && (player.anInt1517 == player.idleAnimation);
			int j1 = player.x >> 7;
			int k1 = player.y >> 7;
			if ((j1 < 0) || (j1 >= 104) || (k1 < 0) || (k1 >= 104)) {
				continue;
			}
			if ((player.aModel_1714 != null) && (Client.loopCycle >= player.anInt1707)
			&& (Client.loopCycle < player.anInt1708)) {
				player.aBoolean1699 = false;
				player.renderHeight = getEntityHeightOffset(plane, player.y, player.x);
				sceneGraph.method286(plane, player.y, player, player.anInt1552, player.anInt1722,
				player.x, player.renderHeight, player.anInt1719, player.anInt1721, i1,
				player.anInt1720);
				continue;
			}
			if (((player.x & 0x7f) == 64) && ((player.y & 0x7f) == 64)) {
				if (anIntArrayArray929[j1][k1] == anInt1265) {
					continue;
				}
				anIntArrayArray929[j1][k1] = anInt1265;
			}
			player.renderHeight = getEntityHeightOffset(plane, player.y, player.x);
			sceneGraph.method285(plane, player.anInt1552, player.renderHeight, i1, player.y, 60,
			player.x, player, player.aBoolean1541);
		}
	}

	private void method49(Packet buffer) {
		for (int j = 0; j < anInt893; j++) {
			int k = anIntArray894[j];
			Player player = playerArray[k];
			int l = buffer.getUnsignedByte();
			if ((l & 0x40) != 0) {
				l += buffer.getUnsignedByte() << 8;
			}
			method107(l, k, buffer, player);
		}
	}

	private void method50(int i, int k, int l, int i1, int j1) {
		int k1 = sceneGraph.method300(j1, l, i);
		if (k1 != 0) {
			int l1 = sceneGraph.method304(j1, l, i, k1);
			int k2 = l1 >> 6 & 3;
			int i3 = l1 & 0x1f;
			int k3 = k;
			if (k1 > 0) {
				k3 = i1;
			}
			int pixels[] = miniMap.pixels;
			int dest = 24624 + l * 4 + (103 - i) * 512 * 4;
			int id = k1 >> 14 & 0x7fff;
			ObjectDefinition object = ObjectDefinition.forID(id);
			if (object.anInt758 != -1) {
				IndexedSprite scenes = mapScenes[object.anInt758];
				if (scenes != null) {
					int i6 = (object.anInt744 * 4 - scenes.width) / 2;
					int j6 = (object.anInt761 * 4 - scenes.height) / 2;
					scenes.drawIndexedSprite(48 + l * 4 + i6, 48 + (104 - i - object.anInt761) * 4
					+ j6);
				}
			} else {
				if ((i3 == 0) || (i3 == 2)) {
					if (k2 == 0) {
						pixels[dest] = k3;
						pixels[dest + 512] = k3;
						pixels[dest + 1024] = k3;
						pixels[dest + 1536] = k3;
					} else if (k2 == 1) {
						pixels[dest] = k3;
						pixels[dest + 1] = k3;
						pixels[dest + 2] = k3;
						pixels[dest + 3] = k3;
					} else if (k2 == 2) {
						pixels[dest + 3] = k3;
						pixels[dest + 3 + 512] = k3;
						pixels[dest + 3 + 1024] = k3;
						pixels[dest + 3 + 1536] = k3;
					} else if (k2 == 3) {
						pixels[dest + 1536] = k3;
						pixels[dest + 1536 + 1] = k3;
						pixels[dest + 1536 + 2] = k3;
						pixels[dest + 1536 + 3] = k3;
					}
				}
				if (i3 == 3) {
					if (k2 == 0) {
						pixels[dest] = k3;
					} else if (k2 == 1) {
						pixels[dest + 3] = k3;
					} else if (k2 == 2) {
						pixels[dest + 3 + 1536] = k3;
					} else if (k2 == 3) {
						pixels[dest + 1536] = k3;
					}
				}
				if (i3 == 2) {
					if (k2 == 3) {
						pixels[dest] = k3;
						pixels[dest + 512] = k3;
						pixels[dest + 1024] = k3;
						pixels[dest + 1536] = k3;
					} else if (k2 == 0) {
						pixels[dest] = k3;
						pixels[dest + 1] = k3;
						pixels[dest + 2] = k3;
						pixels[dest + 3] = k3;
					} else if (k2 == 1) {
						pixels[dest + 3] = k3;
						pixels[dest + 3 + 512] = k3;
						pixels[dest + 3 + 1024] = k3;
						pixels[dest + 3 + 1536] = k3;
					} else if (k2 == 2) {
						pixels[dest + 1536] = k3;
						pixels[dest + 1536 + 1] = k3;
						pixels[dest + 1536 + 2] = k3;
						pixels[dest + 1536 + 3] = k3;
					}
				}
			}
		}
		k1 = sceneGraph.method302(j1, l, i);
		if (k1 != 0) {
			int i2 = sceneGraph.method304(j1, l, i, k1);
			int l2 = i2 >> 6 & 3;
			int j3 = i2 & 0x1f;
			int l3 = k1 >> 14 & 0x7fff;
			ObjectDefinition object = ObjectDefinition.forID(l3);
			if (object.anInt758 != -1) {
				IndexedSprite scenes = mapScenes[object.anInt758];
				if (scenes != null) {
					int j5 = (object.anInt744 * 4 - scenes.width) / 2;
					int k5 = (object.anInt761 * 4 - scenes.height) / 2;
					scenes.drawIndexedSprite(48 + l * 4 + j5, 48 + (104 - i - object.anInt761) * 4
					+ k5);
				}
			} else if (j3 == 9) {
				int l4 = 0xeeeeee;
				if (k1 > 0) {
					l4 = 0xee0000;
				}
				int pixels[] = miniMap.pixels;
				int l5 = 24624 + l * 4 + (103 - i) * 512 * 4;
				if ((l2 == 0) || (l2 == 2)) {
					pixels[l5 + 1536] = l4;
					pixels[l5 + 1024 + 1] = l4;
					pixels[l5 + 512 + 2] = l4;
					pixels[l5 + 3] = l4;
				} else {
					pixels[l5] = l4;
					pixels[l5 + 512 + 1] = l4;
					pixels[l5 + 1024 + 2] = l4;
					pixels[l5 + 1536 + 3] = l4;
				}
			}
		}
		k1 = sceneGraph.method303(j1, l, i);
		if (k1 != 0) {
			int j2 = k1 >> 14 & 0x7fff;
			ObjectDefinition object = ObjectDefinition.forID(j2);
			if (object.anInt758 != -1) {
				IndexedSprite scenes = mapScenes[object.anInt758];
				if (scenes != null) {
					int i4 = (object.anInt744 * 4 - scenes.width) / 2;
					int j4 = (object.anInt761 * 4 - scenes.height) / 2;
					scenes.drawIndexedSprite(48 + l * 4 + i4, 48 + (104 - i - object.anInt761) * 4
					+ j4);
				}
			}
		}
	}

	private int method54() {
		for (int i = 0; i < aByteArrayArray1183.length; i++) {
			if ((aByteArrayArray1183[i] == null) && (anIntArray1235[i] != -1)) {
				return -1;
			}
			if ((aByteArrayArray1247[i] == null) && (anIntArray1236[i] != -1)) {
				return -2;
			}
		}
		boolean flag = true;
		for (int j = 0; j < aByteArrayArray1183.length; j++) {
			byte abyte0[] = aByteArrayArray1247[j];
			if (abyte0 != null) {
				int k = (anIntArray1234[j] >> 8) * 64 - baseX;
				int l = (anIntArray1234[j] & 0xff) * 64 - baseY;
				if (aBoolean1159) {
					k = 10;
					l = 10;
				}
				flag &= Region.method189(k, abyte0, l);
			}
		}
		if (!flag) {
			return -3;
		}
		if (aBoolean1080) {
			return -4;
		} else {
			loadingStage = 2;
			Region.anInt131 = plane;
			method22();
			outputStream.putOperation(121);
			return 0;
		}
	}

	private void renderProjectiles() {
		for (Projectile projectile = (Projectile) projectileList.getFront(); projectile != null; projectile = (Projectile) projectileList
		.getNext()) {
			if ((projectile.anInt1597 != plane) || (Client.loopCycle > projectile.anInt1572)) {
				projectile.unlink();
			} else if (Client.loopCycle >= projectile.anInt1571) {
				if (projectile.anInt1590 > 0) {
					Npc npc = npcArray[projectile.anInt1590 - 1];
					if ((npc != null) && (npc.x >= 0) && (npc.x < 13312) && (npc.y >= 0)
					&& (npc.y < 13312)) {
						projectile.getProjectileHeight(Client.loopCycle, npc.y,
						getEntityHeightOffset(projectile.anInt1597, npc.y, npc.x)
						- projectile.anInt1583, npc.x);
					}
				}
				if (projectile.anInt1590 < 0) {
					int j = -projectile.anInt1590 - 1;
					Player player;
					if (j == unknownInt10) {
						player = Client.myPlayer;
					} else {
						player = playerArray[j];
					}
					if ((player != null) && (player.x >= 0) && (player.x < 13312)
					&& (player.y >= 0) && (player.y < 13312)) {
						projectile.getProjectileHeight(Client.loopCycle, player.y,
						getEntityHeightOffset(projectile.anInt1597, player.y, player.x)
						- projectile.anInt1583, player.x);
					}
				}
				projectile.method456(anInt945);
				sceneGraph.method285(plane, projectile.anInt1595, (int) projectile.aDouble1587, -1,
				(int) projectile.aDouble1586, 60, (int) projectile.aDouble1585, projectile, false);
			}
		}
	}

	private void method60(int i) {
		Interface iComponent = Interface.interfaceCache[i];
		for (int element : iComponent.children) {
			if (element == -1) {
				break;
			}
			Interface childInterface = Interface.interfaceCache[element];
			if (childInterface.type == 1) {
				method60(childInterface.id);
			}
			childInterface.anInt246 = 0;
			childInterface.anInt208 = 0;
		}
	}

	private void method63() {
		NodeSub2 nodeSub2 = (NodeSub2) aClass19_1179.getFront();
		for (; nodeSub2 != null; nodeSub2 = (NodeSub2) aClass19_1179.getNext()) {
			if (nodeSub2.anInt1294 == -1) {
				nodeSub2.anInt1302 = 0;
				method89(nodeSub2);
			} else {
				nodeSub2.unlink();
			}
		}
	}

	private void method65(int i, int j, int k, int l, Interface iComponent, int i1, boolean flag,
	int j1) {
		int anInt992;
		if (aBoolean972) {
			anInt992 = 32;
		} else {
			anInt992 = 0;
		}
		aBoolean972 = false;
		if ((k >= i) && (k < i + 16) && (l >= i1) && (l < i1 + 16)) {
			iComponent.scrollPosition -= anInt1213 * 4;
			if (flag) {
				drawInventoryRequest = true;
			}
		} else if ((k >= i) && (k < i + 16) && (l >= (i1 + j) - 16) && (l < i1 + j)) {
			iComponent.scrollPosition += anInt1213 * 4;
			if (flag) {
				drawInventoryRequest = true;
			}
		} else if ((k >= i - anInt992) && (k < i + 16 + anInt992) && (l >= i1 + 16)
		&& (l < (i1 + j) - 16) && (anInt1213 > 0)) {
			int l1 = ((j - 32) * j) / j1;
			if (l1 < 8) {
				l1 = 8;
			}
			int i2 = l - i1 - 16 - l1 / 2;
			int j2 = j - 32 - l1;
			iComponent.scrollPosition = ((j1 - j) * i2) / j2;
			if (flag) {
				drawInventoryRequest = true;
			}
			aBoolean972 = true;
		}
	}

	private boolean method66(int i, int j, int k) {
		int i1 = i >> 14 & 0x7fff;
		int j1 = sceneGraph.method304(plane, k, j, i);
		if (j1 == -1) {
			return false;
		}
		int k1 = j1 & 0x1f;
		int l1 = j1 >> 6 & 3;
		if ((k1 == 10) || (k1 == 11) || (k1 == 22)) {
			ObjectDefinition class46 = ObjectDefinition.forID(i1);
			int i2;
			int j2;
			if ((l1 == 0) || (l1 == 2)) {
				i2 = class46.anInt744;
				j2 = class46.anInt761;
			} else {
				i2 = class46.anInt761;
				j2 = class46.anInt744;
			}
			int k2 = class46.anInt768;
			if (l1 != 0) {
				k2 = (k2 << l1 & 0xf) + (k2 >> 4 - l1);
			}
			doWalkTo(2, 0, j2, 0, Client.myPlayer.walkQueueY[0], i2, k2, j,
			Client.myPlayer.walkQueueX[0], false, k);
		} else {
			doWalkTo(2, l1, 0, k1 + 1, Client.myPlayer.walkQueueY[0], 0, 0, j,
			Client.myPlayer.walkQueueX[0], false, k);
		}
		crossX = super.saveClickX;
		crossY = super.saveClickY;
		crossType = 2;
		crossIndex = 0;
		return true;
	}

	private void method70() {
		anInt1251 = 0;
		int j = (Client.myPlayer.x >> 7) + baseX;
		int k = (Client.myPlayer.y >> 7) + baseY;
		if ((j >= 3053) && (j <= 3156) && (k >= 3056) && (k <= 3136)) {
			anInt1251 = 1;
		}
		if ((j >= 3072) && (j <= 3118) && (k >= 9492) && (k <= 9535)) {
			anInt1251 = 1;
		}
		if ((anInt1251 == 1) && (j >= 3139) && (j <= 3199) && (k >= 3008) && (k <= 3062)) {
			anInt1251 = 0;
		}
	}

	private void processPlayerInput() {
		do {
			int j = readChar(-796);
			if (j == -1) {
				break;
			}
			if (j == 96) {
				break;
			}
			if (Client.consoleOpen) {
				if ((j == 8) && (consoleInput.length() > 0)) {
					consoleInput = consoleInput.substring(0, consoleInput.length() - 1);
				}
				if ((j >= 32) && (j <= 122) && (consoleInput.length() < 80)) {
					consoleInput += (char) j;
				}
				if (((j == 13) || (j == 10)) && (consoleInput.length() > 0)) {
					printConsoleMessage(consoleInput, 0);
					processConsoleCommand(consoleInput);
					consoleInput = "";
					Client.inputTaken = true;
				}
			} else if ((openInterfaceID != -1) && (openInterfaceID == reportAbuseInterfaceID)) {
				if ((j == 8) && (reportAbuseInput.length() > 0)) {
					reportAbuseInput = reportAbuseInput.substring(0, reportAbuseInput.length() - 1);
				}
				if ((((j >= 97) && (j <= 122)) || ((j >= 65) && (j <= 90))
				|| ((j >= 48) && (j <= 57)) || (j == 32))
				&& (reportAbuseInput.length() < 12)) {
					reportAbuseInput += (char) j;
				}
			} else if (messagePromptRaised) {
				if ((j >= 32) && (j <= 122) && (promptInput.length() < 80)) {
					promptInput += (char) j;
					Client.inputTaken = true;
				}
				if ((j == 8) && (promptInput.length() > 0)) {
					promptInput = promptInput.substring(0, promptInput.length() - 1);
					Client.inputTaken = true;
				}
				if ((j == 13) || (j == 10)) {
					messagePromptRaised = false;
					Client.inputTaken = true;
					if (friendsListAction == 1) {
						long l = TextUtil.longForName(promptInput);
						addFriend(l);
					}
					if ((friendsListAction == 2) && (friendsCount > 0)) {
						long l1 = TextUtil.longForName(promptInput);
						delFriend(l1);
					}
					if ((friendsListAction == 3) && (promptInput.length() > 0)) {
						outputStream.putOperation(126);
						outputStream.putByte(0);
						int k = outputStream.offset;
						outputStream.putLong(aLong953);
						ChatInput.method526(promptInput, outputStream);
						outputStream.putSizeByte(outputStream.offset - k);
						promptInput = ChatInput.processText(promptInput);
						// promptInput = Censor.doCensor(promptInput);
						pushMessage(promptInput, 6, TextUtil
						.fixName(TextUtil.nameForLong(aLong953)));
						if (privateChatMode == 2) {
							privateChatMode = 1;
							outputStream.putOperation(95);
							outputStream.putByte(publicChatMode);
							outputStream.putByte(privateChatMode);
							outputStream.putByte(tradeMode);
						}
					}
					if ((friendsListAction == 4) && (ignoreCount < 100)) {
						long l2 = TextUtil.longForName(promptInput);
						addIgnore(l2);
					}
					if ((friendsListAction == 5) && (ignoreCount > 0)) {
						long l3 = TextUtil.longForName(promptInput);
						removeIgnore(l3);
					}
				}
			} else if (inputDialogState == 1) {
				if ((j >= 48) && (j <= 57) && (amountOrNameInput.length() < 10)) {
					amountOrNameInput += (char) j;
					Client.inputTaken = true;
				}
				if ((j == 8) && (amountOrNameInput.length() > 0)) {
					amountOrNameInput = amountOrNameInput.substring(0,
					amountOrNameInput.length() - 1);
					Client.inputTaken = true;
				}
				if ((j == 13) || (j == 10)) {
					if (amountOrNameInput.length() > 0) {
						int i = 0;
						try {
							i = Integer.parseInt(amountOrNameInput);
						} catch (Exception _ex) {
						}
						outputStream.putOperation(208);
						outputStream.putInt(i);
					}
					inputDialogState = 0;
					Client.inputTaken = true;
				}
			} else if (inputDialogState == 2) {
				if ((j >= 32) && (j <= 122) && (amountOrNameInput.length() < 12)) {
					amountOrNameInput += (char) j;
					Client.inputTaken = true;
				}
				if ((j == 8) && (amountOrNameInput.length() > 0)) {
					amountOrNameInput = amountOrNameInput.substring(0,
					amountOrNameInput.length() - 1);
					Client.inputTaken = true;
				}
				if ((j == 13) || (j == 10)) {
					if (amountOrNameInput.length() > 0) {
						outputStream.putOperation(60);
						outputStream.putLong(TextUtil.longForName(amountOrNameInput));
					}
					inputDialogState = 0;
					Client.inputTaken = true;
				}
			} else if (backDialogID == -1) {
				if ((j >= 32) && (j <= 122) && (inputString.length() < 80)) {
					inputString += (char) j;
					Client.inputTaken = true;
				}
				if ((j == 8) && (inputString.length() > 0)) {
					inputString = inputString.substring(0, inputString.length() - 1);
					Client.inputTaken = true;
				}
				if (((j == 13) || (j == 10)) && (inputString.length() > 0)) {
					if (inputString.startsWith("::")) {
						outputStream.putOperation(103);
						outputStream.putByte(inputString.length() - 1);
						outputStream.putString(inputString.substring(2));
					} else {
						String s = inputString.toLowerCase();
						int j2 = 0;
						if (s.startsWith("yellow:")) {
							j2 = 0;
							inputString = inputString.substring(7);
						} else if (s.startsWith("red:")) {
							j2 = 1;
							inputString = inputString.substring(4);
						} else if (s.startsWith("green:")) {
							j2 = 2;
							inputString = inputString.substring(6);
						} else if (s.startsWith("cyan:")) {
							j2 = 3;
							inputString = inputString.substring(5);
						} else if (s.startsWith("purple:")) {
							j2 = 4;
							inputString = inputString.substring(7);
						} else if (s.startsWith("white:")) {
							j2 = 5;
							inputString = inputString.substring(6);
						} else if (s.startsWith("flash1:")) {
							j2 = 6;
							inputString = inputString.substring(7);
						} else if (s.startsWith("flash2:")) {
							j2 = 7;
							inputString = inputString.substring(7);
						} else if (s.startsWith("flash3:")) {
							j2 = 8;
							inputString = inputString.substring(7);
						} else if (s.startsWith("glow1:")) {
							j2 = 9;
							inputString = inputString.substring(6);
						} else if (s.startsWith("glow2:")) {
							j2 = 10;
							inputString = inputString.substring(6);
						} else if (s.startsWith("glow3:")) {
							j2 = 11;
							inputString = inputString.substring(6);
						}
						s = inputString.toLowerCase();
						int i3 = 0;
						if (s.startsWith("wave:")) {
							i3 = 1;
							inputString = inputString.substring(5);
						} else if (s.startsWith("wave2:")) {
							i3 = 2;
							inputString = inputString.substring(6);
						} else if (s.startsWith("shake:")) {
							i3 = 3;
							inputString = inputString.substring(6);
						} else if (s.startsWith("scroll:")) {
							i3 = 4;
							inputString = inputString.substring(7);
						} else if (s.startsWith("slide:")) {
							i3 = 5;
							inputString = inputString.substring(6);
						}
						outputStream.putOperation(4);
						outputStream.putByte(0);
						int j3 = outputStream.offset;
						outputStream.putByteS(i3);
						outputStream.putByteS(j2);
						chatBuffers.offset = 0;
						ChatInput.method526(inputString, chatBuffers);
						outputStream.getReverseBytesA(chatBuffers.buffer, 0, chatBuffers.offset);
						outputStream.putSizeByte(outputStream.offset - j3);
						inputString = ChatInput.processText(inputString);
						// inputString = Censor.doCensor(inputString);
						Client.myPlayer.textSpoken = inputString;
						Client.myPlayer.anInt1513 = j2;
						Client.myPlayer.textEffects = i3;
						Client.myPlayer.textCycle = 150;
						if (myPrivilege == 2) {
							pushMessage(Client.myPlayer.textSpoken, 2, "@cr2@"
							+ Client.myPlayer.name);
						} else if (myPrivilege == 1) {
							pushMessage(Client.myPlayer.textSpoken, 2, "@cr1@"
							+ Client.myPlayer.name);
						} else {
							pushMessage(Client.myPlayer.textSpoken, 2, Client.myPlayer.name);
						}
						if (publicChatMode == 2) {
							publicChatMode = 3;
							outputStream.putOperation(95);
							outputStream.putByte(publicChatMode);
							outputStream.putByte(privateChatMode);
							outputStream.putByte(tradeMode);
						}
					}
					inputString = "";
					Client.inputTaken = true;
				}
			}
		} while (true);
	}

	private void method81(Sprite sprite, int j, int x) {
		int l = x * x + j * j;
		if ((l > 4225) && (l < 0x15f90)) {
			int i1 = minimapAndCompassRotation + minimapRotation & 0x7ff;
			int j1 = Model.sineTable[i1];
			int k1 = Model.cosineTable[i1];
			j1 = (j1 * 256) / (minimapZoom + 256);
			k1 = (k1 * 256) / (minimapZoom + 256);
			int l1 = j * j1 + x * k1 >> 16;
			int i2 = j * k1 - x * j1 >> 16;
			double d = Math.atan2(l1, i2);
			int j2 = (int) (Math.sin(d) * 63D);
			int k2 = (int) (Math.cos(d) * 57D);
			mapEdge.method353(83 - k2 - 20, d, (94 + j2 + 4) - 10);
		} else {
			markMinimap(sprite, x, j);
		}
	}

	private int method83(int i, int j, int k) {
		int l = 256 - k;
		return ((i & 0xff00ff) * l + (j & 0xff00ff) * k & 0xff00ff00)
		+ ((i & 0xff00) * l + (j & 0xff00) * k & 0xff0000) >> 8;
	}

	private void method86(Packet buffer) {
		for (int j = 0; j < anInt893; j++) {
			int k = anIntArray894[j];
			Npc npc = npcArray[k];
			int l = buffer.getUnsignedByte();
			if ((l & 0x10) != 0) {
				int i1 = buffer.getUnsignedLEShort();
				if (i1 == 65535) {
					i1 = -1;
				}
				int i2 = buffer.getUnsignedByte();
				if ((i1 == npc.currentAnimation) && (i1 != -1)) {
					int l2 = Animation.animations[i1].anInt365;
					if (l2 == 1) {
						npc.anInt1527 = 0;
						npc.anInt1528 = 0;
						npc.animationDelay = i2;
						npc.anInt1530 = 0;
					}
					if (l2 == 2) {
						npc.anInt1530 = 0;
					}
				} else if ((i1 == -1)
				|| (npc.currentAnimation == -1)
				|| (Animation.animations[i1].anInt359 >= Animation.animations[npc.currentAnimation].anInt359)) {
					npc.currentAnimation = i1;
					npc.anInt1527 = 0;
					npc.anInt1528 = 0;
					npc.animationDelay = i2;
					npc.anInt1530 = 0;
					npc.anInt1542 = npc.smallXYIndex;
				}
			}
			if ((l & 8) != 0) {
				int j1 = buffer.getUnsignedByteA();
				int j2 = buffer.getUnsignedByteC();
				npc.updateHitData(j2, j1, Client.loopCycle);
				npc.combatCycle = Client.loopCycle + 300;
				npc.currentHealth = buffer.getUnsignedByteA();
				npc.maxHealth = buffer.getUnsignedByte();
			}
			if ((l & 0x80) != 0) {
				npc.anInt1520 = buffer.getUnsignedShort();
				int k1 = buffer.getInt();
				npc.anInt1524 = k1 >> 16;
				npc.anInt1523 = Client.loopCycle + (k1 & 0xffff);
				npc.anInt1521 = 0;
				npc.anInt1522 = 0;
				if (npc.anInt1523 > Client.loopCycle) {
					npc.anInt1521 = -1;
				}
				if (npc.anInt1520 == 65535) {
					npc.anInt1520 = -1;
				}
			}
			if ((l & 0x20) != 0) {
				npc.interactingEntity = buffer.getUnsignedShort();
				if (npc.interactingEntity == 65535) {
					npc.interactingEntity = -1;
				}
			}
			if ((l & 1) != 0) {
				npc.textSpoken = buffer.getString();
				npc.textCycle = 100;
			}
			if ((l & 0x40) != 0) {
				int l1 = buffer.getUnsignedByteC();
				int k2 = buffer.getUnsignedByteS();
				npc.updateHitData(k2, l1, Client.loopCycle);
				npc.combatCycle = Client.loopCycle + 300;
				npc.currentHealth = buffer.getUnsignedByteS();
				npc.maxHealth = buffer.getUnsignedByteC();
			}
			if ((l & 2) != 0) {
				npc.desc = EntityDefinition.forID(buffer.getUnsignedShortA());
				npc.boundingCube = npc.desc.aByte68;
				npc.anInt1504 = npc.desc.anInt79;
				npc.walkAnimation = npc.desc.walkAnim;
				npc.anInt1555 = npc.desc.anInt58;
				npc.anInt1556 = npc.desc.anInt83;
				npc.anInt1557 = npc.desc.anInt55;
				npc.idleAnimation = npc.desc.standAnim;
			}
			if ((l & 4) != 0) {
				npc.anInt1538 = buffer.getUnsignedLEShort();
				npc.anInt1539 = buffer.getUnsignedLEShort();
			}
		}
	}

	private void method89(NodeSub2 nodeSub2) {
		int i = 0;
		int j = -1;
		int k = 0;
		int l = 0;
		if (nodeSub2.anInt1296 == 0) {
			i = sceneGraph.method300(nodeSub2.anInt1295, nodeSub2.anInt1297, nodeSub2.anInt1298);
		}
		if (nodeSub2.anInt1296 == 1) {
			i = sceneGraph.method301(nodeSub2.anInt1295, nodeSub2.anInt1297, nodeSub2.anInt1298);
		}
		if (nodeSub2.anInt1296 == 2) {
			i = sceneGraph.method302(nodeSub2.anInt1295, nodeSub2.anInt1297, nodeSub2.anInt1298);
		}
		if (nodeSub2.anInt1296 == 3) {
			i = sceneGraph.method303(nodeSub2.anInt1295, nodeSub2.anInt1297, nodeSub2.anInt1298);
		}
		if (i != 0) {
			int i1 = sceneGraph.method304(nodeSub2.anInt1295, nodeSub2.anInt1297,
			nodeSub2.anInt1298, i);
			j = i >> 14 & 0x7fff;
			k = i1 & 0x1f;
			l = i1 >> 6;
		}
		nodeSub2.anInt1299 = j;
		nodeSub2.anInt1301 = k;
		nodeSub2.anInt1300 = l;
	}

	private void method90() {
		for (int i = 0; i < anInt1062; i++) {
			if (anIntArray1250[i] <= 0) {
				boolean flag1 = false;
				try {
					if ((anIntArray1207[i] == anInt874) && (anIntArray1241[i] == anInt1289)) {
						if (!replayWave()) {
							flag1 = true;
						}
					} else {
						Packet buffer = Sounds.method241(anIntArray1241[i], anIntArray1207[i]);
						if (System.currentTimeMillis() + (buffer.offset / 22) > aLong1172
						+ (anInt1257 / 22)) {
							anInt1257 = buffer.offset;
							aLong1172 = System.currentTimeMillis();
							if (saveWave(buffer.buffer, buffer.offset)) {
								anInt874 = anIntArray1207[i];
								anInt1289 = anIntArray1241[i];
							} else {
								flag1 = true;
							}
						}
					}
				} catch (Exception exception) {
				}
				if (!flag1 || (anIntArray1250[i] == -5)) {
					anInt1062--;
					for (int j = i; j < anInt1062; j++) {
						anIntArray1207[j] = anIntArray1207[j + 1];
						anIntArray1241[j] = anIntArray1241[j + 1];
						anIntArray1250[j] = anIntArray1250[j + 1];
					}
					i--;
				} else {
					anIntArray1250[i] = -5;
				}
			} else {
				anIntArray1250[i]--;
			}
		}
		if (prevSong > 0) {
			prevSong -= 20;
			if (prevSong < 0) {
				prevSong = 0;
			}
			if ((prevSong == 0) && musicEnabled && !Client.lowMem) {
				nextSong = currentSong;
				songChanging = true;
				onDemandFetcher.method558(2, nextSong);
			}
		}
	}

	private void method91(Packet buffer, int i) {
		while (buffer.bitOffset + 10 < i * 8) {
			int j = buffer.getBits(11);
			if (j == 2047) {
				break;
			}
			if (playerArray[j] == null) {
				playerArray[j] = new Player();
				if (playerAppearanceBuffers[j] != null) {
					playerArray[j].updatePlayer(playerAppearanceBuffers[j]);
				}
			}
			playerIndices[playerCount++] = j;
			Player player = playerArray[j];
			player.anInt1537 = Client.loopCycle;
			int k = buffer.getBits(1);
			if (k == 1) {
				anIntArray894[anInt893++] = j;
			}
			int l = buffer.getBits(1);
			int i1 = buffer.getBits(5);
			if (i1 > 15) {
				i1 -= 32;
			}
			int j1 = buffer.getBits(5);
			if (j1 > 15) {
				j1 -= 32;
			}
			player.setPos(Client.myPlayer.walkQueueX[0] + j1, Client.myPlayer.walkQueueY[0] + i1,
			l == 1);
		}
		buffer.finishBitAccess();
	}

	private void method95() {
		for (int j = 0; j < npcCount; j++) {
			int k = npcIndices[j];
			Npc npc = npcArray[k];
			if (npc != null) {
				method96(npc);
			}
		}
	}

	private void method96(Entity entity) {
		if ((entity.x < 128) || (entity.y < 128) || (entity.x >= 13184) || (entity.y >= 13184)) {
			entity.currentAnimation = -1;
			entity.anInt1520 = -1;
			entity.anInt1547 = 0;
			entity.anInt1548 = 0;
			entity.x = entity.walkQueueX[0] * 128 + entity.boundingCube * 64;
			entity.y = entity.walkQueueY[0] * 128 + entity.boundingCube * 64;
			entity.method446();
		}
		if ((entity == Client.myPlayer)
		&& ((entity.x < 1536) || (entity.y < 1536) || (entity.x >= 11776) || (entity.y >= 11776))) {
			entity.currentAnimation = -1;
			entity.anInt1520 = -1;
			entity.anInt1547 = 0;
			entity.anInt1548 = 0;
			entity.x = entity.walkQueueX[0] * 128 + entity.boundingCube * 64;
			entity.y = entity.walkQueueY[0] * 128 + entity.boundingCube * 64;
			entity.method446();
		}
		if (entity.anInt1547 > Client.loopCycle) {
			method97(entity);
		} else if (entity.anInt1548 >= Client.loopCycle) {
			method98(entity);
		} else {
			method99(entity);
		}
		method100(entity);
		method101(entity);
	}

	private void method97(Entity entity) {
		int i = entity.anInt1547 - Client.loopCycle;
		int j = entity.anInt1543 * 128 + entity.boundingCube * 64;
		int k = entity.anInt1545 * 128 + entity.boundingCube * 64;
		entity.x += (j - entity.x) / i;
		entity.y += (k - entity.y) / i;
		entity.anInt1503 = 0;
		if (entity.anInt1549 == 0) {
			entity.turnDirection = 1024;
		}
		if (entity.anInt1549 == 1) {
			entity.turnDirection = 1536;
		}
		if (entity.anInt1549 == 2) {
			entity.turnDirection = 0;
		}
		if (entity.anInt1549 == 3) {
			entity.turnDirection = 512;
		}
	}

	private void method98(Entity entity) {
		if ((entity.anInt1548 == Client.loopCycle)
		|| (entity.currentAnimation == -1)
		|| (entity.animationDelay != 0)
		|| (entity.anInt1528 + 1 > Animation.animations[entity.currentAnimation]
		.method258(entity.anInt1527))) {
			int i = entity.anInt1548 - entity.anInt1547;
			int j = Client.loopCycle - entity.anInt1547;
			int k = entity.anInt1543 * 128 + entity.boundingCube * 64;
			int l = entity.anInt1545 * 128 + entity.boundingCube * 64;
			int i1 = entity.anInt1544 * 128 + entity.boundingCube * 64;
			int j1 = entity.anInt1546 * 128 + entity.boundingCube * 64;
			entity.x = (k * (i - j) + i1 * j) / i;
			entity.y = (l * (i - j) + j1 * j) / i;
		}
		entity.anInt1503 = 0;
		if (entity.anInt1549 == 0) {
			entity.turnDirection = 1024;
		}
		if (entity.anInt1549 == 1) {
			entity.turnDirection = 1536;
		}
		if (entity.anInt1549 == 2) {
			entity.turnDirection = 0;
		}
		if (entity.anInt1549 == 3) {
			entity.turnDirection = 512;
		}
		entity.anInt1552 = entity.turnDirection;
	}

	private void method99(Entity entity) {
		entity.anInt1517 = entity.idleAnimation;
		if (entity.smallXYIndex == 0) {
			entity.anInt1503 = 0;
			return;
		}
		if ((entity.currentAnimation != -1) && (entity.animationDelay == 0)) {
			Animation animation = Animation.animations[entity.currentAnimation];
			if ((entity.anInt1542 > 0) && (animation.anInt363 == 0)) {
				entity.anInt1503++;
				return;
			}
			if ((entity.anInt1542 <= 0) && (animation.walkType == 0)) {
				entity.anInt1503++;
				return;
			}
		}
		int i = entity.x;
		int j = entity.y;
		int k = entity.walkQueueX[entity.smallXYIndex - 1] * 128 + entity.boundingCube * 64;
		int l = entity.walkQueueY[entity.smallXYIndex - 1] * 128 + entity.boundingCube * 64;
		if ((k - i > 256) || (k - i < -256) || (l - j > 256) || (l - j < -256)) {
			entity.x = k;
			entity.y = l;
			return;
		}
		if (i < k) {
			if (j < l) {
				entity.turnDirection = 1280;
			} else if (j > l) {
				entity.turnDirection = 1792;
			} else {
				entity.turnDirection = 1536;
			}
		} else if (i > k) {
			if (j < l) {
				entity.turnDirection = 768;
			} else if (j > l) {
				entity.turnDirection = 256;
			} else {
				entity.turnDirection = 512;
			}
		} else if (j < l) {
			entity.turnDirection = 1024;
		} else {
			entity.turnDirection = 0;
		}
		int i1 = entity.turnDirection - entity.anInt1552 & 0x7ff;
		if (i1 > 1024) {
			i1 -= 2048;
		}
		int j1 = entity.anInt1555;
		if ((i1 >= -256) && (i1 <= 256)) {
			j1 = entity.walkAnimation;
		} else if ((i1 >= 256) && (i1 < 768)) {
			j1 = entity.anInt1557;
		} else if ((i1 >= -768) && (i1 <= -256)) {
			j1 = entity.anInt1556;
		}
		if (j1 == -1) {
			j1 = entity.walkAnimation;
		}
		entity.anInt1517 = j1;
		int k1 = 4;
		if ((entity.anInt1552 != entity.turnDirection) && (entity.interactingEntity == -1)
		&& (entity.anInt1504 != 0)) {
			k1 = 2;
		}
		if (entity.smallXYIndex > 2) {
			k1 = 6;
		}
		if (entity.smallXYIndex > 3) {
			k1 = 8;
		}
		if ((entity.anInt1503 > 0) && (entity.smallXYIndex > 1)) {
			k1 = 8;
			entity.anInt1503--;
		}
		if (entity.runningFlags[entity.smallXYIndex - 1]) {
			k1 <<= 1;
		}
		if ((k1 >= 8) && (entity.anInt1517 == entity.walkAnimation) && (entity.runAnimation != -1)) {
			entity.anInt1517 = entity.runAnimation;
		}
		if (i < k) {
			entity.x += k1;
			if (entity.x > k) {
				entity.x = k;
			}
		} else if (i > k) {
			entity.x -= k1;
			if (entity.x < k) {
				entity.x = k;
			}
		}
		if (j < l) {
			entity.y += k1;
			if (entity.y > l) {
				entity.y = l;
			}
		} else if (j > l) {
			entity.y -= k1;
			if (entity.y < l) {
				entity.y = l;
			}
		}
		if ((entity.x == k) && (entity.y == l)) {
			entity.smallXYIndex--;
			if (entity.anInt1542 > 0) {
				entity.anInt1542--;
			}
		}
	}

	private void worldToScreen(Entity entity, int i) {
		getEntityScreenPos(entity.x, i, entity.y);
	}

	private void nullLoader() {
		flameRequest = false;
		while (drawingFlames) {
			flameRequest = false;
			try {
				Thread.sleep(50L);
			} catch (Exception _ex) {
			}
		}
		titleBox = null;
		titleButton = null;
		runes = null;
		anIntArray850 = null;
		anIntArray851 = null;
		anIntArray852 = null;
		anIntArray853 = null;
		anIntArray1190 = null;
		anIntArray1191 = null;
		anIntArray828 = null;
		anIntArray829 = null;
		leftFlame = null;
		rightFlame = null;
	}

	private DataInputStream openJagGrabInputStream(String url) throws IOException {
		// if(!aBoolean872)
		// if(signlink.mainapp != null)
		// return signlink.openurl(url);
		// else
		// return new DataInputStream((new URL(getCodeBase(), url)).openStream());
		if (socket != null) {
			try {
				socket.close();
			} catch (Exception _ex) {
			}
			socket = null;
		}
		socket = openSocket(43595);
		socket.setSoTimeout(10000);
		InputStream inputstream = socket.getInputStream();
		OutputStream outputstream = socket.getOutputStream();
		outputstream.write(("JAGGRAB /" + url + "\n\n").getBytes());
		return new DataInputStream(inputstream);
	}

	public java.net.Socket openSocket(int port) throws IOException {
		return new java.net.Socket(InetAddress.getByName(Client.server), port);
	}

	private boolean parsePacket() {
		if (socketStream == null) {
			return false;
		}
		try {
			int i = socketStream.available();
			if (i == 0) {
				return false;
			}
			if (packetType == -1) {
				socketStream.flushInputStream(inputStream.buffer, 1);
				packetType = inputStream.buffer[0] & 0xff;
				if (encryption != null) {
					packetType = packetType - encryption.getNextKey() & 0xff;
				}
				packetSize = SizeConstants.packetSizes[packetType];
				i--;
			}
			if (packetSize == -1) {
				if (i > 0) {
					socketStream.flushInputStream(inputStream.buffer, 1);
					packetSize = inputStream.buffer[0] & 0xff;
					i--;
				} else {
					return false;
				}
			}
			if (packetSize == -2) {
				if (i > 1) {
					socketStream.flushInputStream(inputStream.buffer, 2);
					inputStream.offset = 0;
					packetSize = inputStream.getUnsignedShort();
					i -= 2;
				} else {
					return false;
				}
			}
			if (i < packetSize) {
				return false;
			}
			inputStream.offset = 0;
			socketStream.flushInputStream(inputStream.buffer, packetSize);
			anInt1009 = 0;
			anInt843 = anInt842;
			anInt842 = anInt841;
			anInt841 = packetType;
			switch (packetType) {
				case 81:
					updatePlayers(packetSize, inputStream);
					aBoolean1080 = false;
					packetType = -1;
					return true;
				case 176:
					recoveriesLastSet = inputStream.getUnsignedByteC();
					unreadMessages = inputStream.getUnsignedLEShortA();
					membersInt = inputStream.getUnsignedByte();
					anInt1193 = inputStream.getInt1();
					daysSinceLastLogin = inputStream.getUnsignedShort();
					if ((anInt1193 != 0) && (openInterfaceID == -1)) {
						Signlink.dnslookup(TextUtil.method586(anInt1193));
						clearTopInterfaces();
						char c = '\u028A';
						if ((recoveriesLastSet != 201) || (membersInt == 1)) {
							c = '\u028F';
						}
						reportAbuseInput = "";
						canMute = false;
						for (Interface element : Interface.interfaceCache) {
							if ((element == null) || (element.contentType != c)) {
								continue;
							}
							openInterfaceID = element.parentID;
						}
					}
					packetType = -1;
					return true;
				case 64:
					anInt1268 = inputStream.getUnsignedByteC();
					anInt1269 = inputStream.getUnsignedByteS();
					for (int j = anInt1268; j < anInt1268 + 8; j++) {
						for (int l9 = anInt1269; l9 < anInt1269 + 8; l9++) {
							if (groundArray[plane][j][l9] != null) {
								groundArray[plane][j][l9] = null;
								spawnGroundItem(j, l9);
							}
						}
					}
					for (NodeSub2 nodeSub2 = (NodeSub2) aClass19_1179.getFront(); nodeSub2 != null; nodeSub2 = (NodeSub2) aClass19_1179
					.getNext()) {
						if ((nodeSub2.anInt1297 >= anInt1268)
						&& (nodeSub2.anInt1297 < anInt1268 + 8)
						&& (nodeSub2.anInt1298 >= anInt1269)
						&& (nodeSub2.anInt1298 < anInt1269 + 8) && (nodeSub2.anInt1295 == plane)) {
							nodeSub2.anInt1294 = 0;
						}
					}
					packetType = -1;
					return true;
				case 185:
					int opcode = inputStream.getUnsignedShortA();
					Interface.interfaceCache[opcode].anInt233 = 3;
					if (Client.myPlayer.desc == null) {
						Interface.interfaceCache[opcode].mediaID = (Client.myPlayer.anIntArray1700[0] << 25)
						+ (Client.myPlayer.anIntArray1700[4] << 20)
						+ (Client.myPlayer.equipment[0] << 15)
						+ (Client.myPlayer.equipment[8] << 10)
						+ (Client.myPlayer.equipment[11] << 5) + Client.myPlayer.equipment[1];
					} else {
						Interface.interfaceCache[opcode].mediaID = (int) (0x12345678L + Client.myPlayer.desc.type);
					}
					packetType = -1;
					return true;
					// Clan chat packet
				case 217:
					try {
						name = inputStream.getString();
						message = inputStream.getString();
						clanName = inputStream.getString();
						rights = inputStream.getUnsignedShort();
						message = ChatInput.processText(message);
						// message = Censor.doCensor(message);
						System.out.println(clanName);
						pushMessage(message, 16, name);
					} catch (Exception e) {
						e.printStackTrace();
					}
					packetType = -1;
					return true;
				case 107:
					aBoolean1160 = false;
					for (int l = 0; l < 5; l++) {
						aBooleanArray876[l] = false;
					}
					packetType = -1;
					return true;
				case 72:
					int id = inputStream.getUnsignedLEShort();
					Interface iComponent_1 = Interface.interfaceCache[id];
					for (int i2 = 0; i2 < iComponent_1.inv.length; i2++) {
						iComponent_1.inv[i2] = -1;
						iComponent_1.inv[i2] = 0;
					}
					packetType = -1;
					return true;
				case 214:
					ignoreCount = packetSize / 8;
					for (int j1 = 0; j1 < ignoreCount; j1++) {
						ignoreListAsLongs[j1] = inputStream.getLong();
					}
					packetType = -1;
					return true;
				case 166:
					aBoolean1160 = true;
					anInt1098 = inputStream.getUnsignedByte();
					anInt1099 = inputStream.getUnsignedByte();
					anInt1100 = inputStream.getUnsignedShort();
					anInt1101 = inputStream.getUnsignedByte();
					anInt1102 = inputStream.getUnsignedByte();
					if (anInt1102 >= 100) {
						xCameraPos = anInt1098 * 128 + 64;
						yCameraPos = anInt1099 * 128 + 64;
						zCameraPos = getEntityHeightOffset(plane, yCameraPos, xCameraPos)
						- anInt1100;
					}
					packetType = -1;
					return true;
				case 134:
					drawInventoryRequest = true;
					int k1 = inputStream.getUnsignedByte();
					int i10 = inputStream.getInt2();
					int l15 = inputStream.getUnsignedByte();
					currentExp[k1] = i10;
					currentStats[k1] = l15;
					maxStats[k1] = 1;
					for (int k20 = 0; k20 < 98; k20++) {
						if (i10 >= Client.anIntArray1019[k20]) {
							maxStats[k1] = k20 + 2;
						}
					}
					packetType = -1;
					return true;
				case 71:
					int l1 = inputStream.getUnsignedShort();
					int j10 = inputStream.getUnsignedByteA();
					if (l1 == 65535) {
						l1 = -1;
					}
					tabInterfaceIDs[j10] = l1;
					drawInventoryRequest = true;
					inventoryAltered = true;
					packetType = -1;
					return true;
				case 74:
					int i2 = inputStream.getUnsignedLEShort();
					if (i2 == 65535) {
						i2 = -1;
					}
					if ((i2 != currentSong) && musicEnabled && !Client.lowMem && (prevSong == 0)) {
						nextSong = i2;
						songChanging = true;
						onDemandFetcher.method558(2, nextSong);
					}
					currentSong = i2;
					packetType = -1;
					return true;
				case 121:
					int j2 = inputStream.getUnsignedShortA();
					int k10 = inputStream.getUnsignedLEShortA();
					if (musicEnabled && !Client.lowMem) {
						nextSong = j2;
						songChanging = false;
						onDemandFetcher.method558(2, nextSong);
						prevSong = k10;
					}
					packetType = -1;
					return true;
				case 109:
					resetLogout();
					packetType = -1;
					return false;
				case 70:
					int k2 = inputStream.getShort();
					int l10 = inputStream.getLEShort();
					int i16 = inputStream.getUnsignedLEShort();
					Interface iComponent_2 = Interface.interfaceCache[i16];
					iComponent_2.anInt263 = k2;
					iComponent_2.anInt265 = l10;
					packetType = -1;
					return true;
				case 73:
				case 241:
					int l2 = anInt1069;
					int i11 = anInt1070;
					if (packetType == 73) {
						l2 = inputStream.getUnsignedLEShortA();
						i11 = inputStream.getUnsignedShort();
						aBoolean1159 = false;
					}
					if (packetType == 241) {
						i11 = inputStream.getUnsignedLEShortA();
						inputStream.initBitAccess();
						for (int j16 = 0; j16 < 4; j16++) {
							for (int l20 = 0; l20 < 13; l20++) {
								for (int j23 = 0; j23 < 13; j23++) {
									int i26 = inputStream.getBits(1);
									if (i26 == 1) {
										anIntArrayArrayArray1129[j16][l20][j23] = inputStream
										.getBits(26);
									} else {
										anIntArrayArrayArray1129[j16][l20][j23] = -1;
									}
								}
							}
						}
						inputStream.finishBitAccess();
						l2 = inputStream.getUnsignedShort();
						aBoolean1159 = true;
					}
					if ((anInt1069 == l2) && (anInt1070 == i11) && (loadingStage == 2)) {
						packetType = -1;
						return true;
					}
					anInt1069 = l2;
					anInt1070 = i11;
					baseX = (anInt1069 - 6) * 8;
					baseY = (anInt1070 - 6) * 8;
					aBoolean1141 = ((anInt1069 / 8 == 48) || (anInt1069 / 8 == 49))
					&& (anInt1070 / 8 == 48);
					if ((anInt1069 / 8 == 48) && (anInt1070 / 8 == 148)) {
						aBoolean1141 = true;
					}
					loadingStage = 1;
					aLong824 = System.currentTimeMillis();
					gameScreenCanvas.init();
					plainText.drawCenteredText("Loading - please wait.", 257, 151, 0);
					plainText.drawCenteredText("Loading - please wait.", 256, 150, 0xffffff);
					gameScreenCanvas.drawGraphics(super.graphics, 4, 4);
					if (packetType == 73) {
						int k16 = 0;
						for (int i21 = (anInt1069 - 6) / 8; i21 <= (anInt1069 + 6) / 8; i21++) {
							for (int k23 = (anInt1070 - 6) / 8; k23 <= (anInt1070 + 6) / 8; k23++) {
								k16++;
							}
						}
						aByteArrayArray1183 = new byte[k16][];
						aByteArrayArray1247 = new byte[k16][];
						anIntArray1234 = new int[k16];
						anIntArray1235 = new int[k16];
						anIntArray1236 = new int[k16];
						k16 = 0;
						for (int l23 = (anInt1069 - 6) / 8; l23 <= (anInt1069 + 6) / 8; l23++) {
							for (int j26 = (anInt1070 - 6) / 8; j26 <= (anInt1070 + 6) / 8; j26++) {
								anIntArray1234[k16] = (l23 << 8) + j26;
								if (aBoolean1141
								&& ((j26 == 49) || (j26 == 149) || (j26 == 147) || (l23 == 50) || ((l23 == 49) && (j26 == 47)))) {
									anIntArray1235[k16] = -1;
									anIntArray1236[k16] = -1;
									k16++;
								} else {
									int k28 = anIntArray1235[k16] = onDemandFetcher.method562(0,
									j26, l23);
									if (k28 != -1) {
										onDemandFetcher.method558(3, k28);
									}
									int j30 = anIntArray1236[k16] = onDemandFetcher.method562(1,
									j26, l23);
									if (j30 != -1) {
										onDemandFetcher.method558(3, j30);
									}
									k16++;
								}
							}
						}
					}
					if (packetType == 241) {
						int l16 = 0;
						int ai[] = new int[676];
						for (int i24 = 0; i24 < 4; i24++) {
							for (int k26 = 0; k26 < 13; k26++) {
								for (int l28 = 0; l28 < 13; l28++) {
									int k30 = anIntArrayArrayArray1129[i24][k26][l28];
									if (k30 != -1) {
										int k31 = k30 >> 14 & 0x3ff;
										int i32 = k30 >> 3 & 0x7ff;
										int k32 = (k31 / 8 << 8) + i32 / 8;
										for (int j33 = 0; j33 < l16; j33++) {
											if (ai[j33] != k32) {
												continue;
											}
											k32 = -1;
										}
										if (k32 != -1) {
											ai[l16++] = k32;
										}
									}
								}
							}
						}
						aByteArrayArray1183 = new byte[l16][];
						aByteArrayArray1247 = new byte[l16][];
						anIntArray1234 = new int[l16];
						anIntArray1235 = new int[l16];
						anIntArray1236 = new int[l16];
						for (int l26 = 0; l26 < l16; l26++) {
							int i29 = anIntArray1234[l26] = ai[l26];
							int l30 = i29 >> 8 & 0xff;
							int l31 = i29 & 0xff;
							int j32 = anIntArray1235[l26] = onDemandFetcher.method562(0, l31, l30);
							if (j32 != -1) {
								onDemandFetcher.method558(3, j32);
							}
							int i33 = anIntArray1236[l26] = onDemandFetcher.method562(1, l31, l30);
							if (i33 != -1) {
								onDemandFetcher.method558(3, i33);
							}
						}
					}
					int i17 = baseX - anInt1036;
					int j21 = baseY - anInt1037;
					anInt1036 = baseX;
					anInt1037 = baseY;
					for (int j24 = 0; j24 < 16384; j24++) {
						Npc npc = npcArray[j24];
						if (npc != null) {
							for (int j29 = 0; j29 < 10; j29++) {
								npc.walkQueueX[j29] -= i17;
								npc.walkQueueY[j29] -= j21;
							}
							npc.x -= i17 * 128;
							npc.y -= j21 * 128;
						}
					}
					for (int i27 = 0; i27 < maxPlayers; i27++) {
						Player player = playerArray[i27];
						if (player != null) {
							for (int i31 = 0; i31 < 10; i31++) {
								player.walkQueueX[i31] -= i17;
								player.walkQueueY[i31] -= j21;
							}
							player.x -= i17 * 128;
							player.y -= j21 * 128;
						}
					}
					aBoolean1080 = true;
					byte byte1 = 0;
					byte byte2 = 104;
					byte byte3 = 1;
					if (i17 < 0) {
						byte1 = 103;
						byte2 = -1;
						byte3 = -1;
					}
					byte byte4 = 0;
					byte byte5 = 104;
					byte byte6 = 1;
					if (j21 < 0) {
						byte4 = 103;
						byte5 = -1;
						byte6 = -1;
					}
					for (int k33 = byte1; k33 != byte2; k33 += byte3) {
						for (int l33 = byte4; l33 != byte5; l33 += byte6) {
							int i34 = k33 + i17;
							int j34 = l33 + j21;
							for (int k34 = 0; k34 < 4; k34++) {
								if ((i34 >= 0) && (j34 >= 0) && (i34 < 104) && (j34 < 104)) {
									groundArray[k34][k33][l33] = groundArray[k34][i34][j34];
								} else {
									groundArray[k34][k33][l33] = null;
								}
							}
						}
					}
					for (NodeSub2 nodeSub2 = (NodeSub2) aClass19_1179.getFront(); nodeSub2 != null; nodeSub2 = (NodeSub2) aClass19_1179
					.getNext()) {
						nodeSub2.anInt1297 -= i17;
						nodeSub2.anInt1298 -= j21;
						if ((nodeSub2.anInt1297 < 0) || (nodeSub2.anInt1298 < 0)
						|| (nodeSub2.anInt1297 >= 104) || (nodeSub2.anInt1298 >= 104)) {
							nodeSub2.unlink();
						}
					}
					if (destX != 0) {
						destX -= i17;
						destY -= j21;
					}
					aBoolean1160 = false;
					packetType = -1;
					return true;
				case 208:
					int i3 = inputStream.getLEShort();
					if (i3 >= 0) {
						method60(i3);
					}
					anInt1018 = i3;
					packetType = -1;
					return true;
				case 99:
					anInt1021 = inputStream.getUnsignedByte();
					packetType = -1;
					return true;
				case 75:
					int j3 = inputStream.getUnsignedShortA();
					int j11 = inputStream.getUnsignedShortA();
					Interface.interfaceCache[j11].anInt233 = 2;
					Interface.interfaceCache[j11].mediaID = j3;
					packetType = -1;
					return true;
				case 114:
					anInt1104 = inputStream.getUnsignedLEShort() * 30;
					packetType = -1;
					return true;
				case 60:
					anInt1269 = inputStream.getUnsignedByte();
					anInt1268 = inputStream.getUnsignedByteC();
					while (inputStream.offset < packetSize) {
						int k3 = inputStream.getUnsignedByte();
						method137(inputStream, k3);
					}
					packetType = -1;
					return true;
				case 35:
					int l3 = inputStream.getUnsignedByte();
					int k11 = inputStream.getUnsignedByte();
					int j17 = inputStream.getUnsignedByte();
					int k21 = inputStream.getUnsignedByte();
					aBooleanArray876[l3] = true;
					anIntArray873[l3] = k11;
					anIntArray1203[l3] = j17;
					anIntArray928[l3] = k21;
					anIntArray1030[l3] = 0;
					packetType = -1;
					return true;
				case 174:
					int i4 = inputStream.getUnsignedShort();
					int l11 = inputStream.getUnsignedByte();
					int k17 = inputStream.getUnsignedShort();
					if (aBoolean848 && !Client.lowMem && (anInt1062 < 50)) {
						anIntArray1207[anInt1062] = i4;
						anIntArray1241[anInt1062] = l11;
						anIntArray1250[anInt1062] = k17 + Sounds.anIntArray326[i4];
						anInt1062++;
					}
					packetType = -1;
					return true;
				case 104:
					int j4 = inputStream.getUnsignedByteC();
					int i12 = inputStream.getUnsignedByteA();
					String s6 = inputStream.getString();
					if ((j4 >= 1) && (j4 <= 5)) {
						if (s6.equalsIgnoreCase("null")) {
							s6 = null;
						}
						atPlayerActions[j4 - 1] = s6;
						atPlayerArray[j4 - 1] = i12 == 0;
					}
					packetType = -1;
					return true;
				case 78:
					destX = 0;
					packetType = -1;
					return true;
				case 253:
					String s = inputStream.getString();
					if (Client.consoleOpen) {
						printConsoleMessage(s, 1);
					} else if (s.endsWith(":tradereq:")) {
						String s3 = s.substring(0, s.indexOf(":"));
						long l17 = TextUtil.longForName(s3);
						boolean flag2 = false;
						for (int j27 = 0; j27 < ignoreCount; j27++) {
							if (ignoreListAsLongs[j27] != l17) {
								continue;
							}
							flag2 = true;
						}
						if (!flag2 && (anInt1251 == 0)) {
							pushMessage("wishes to trade with you.", 4, s3);
						}
					} else if (s.endsWith("#url#")) {
						String link = s.substring(0, s.indexOf("#"));
						pushMessage("Join us at: ", 9, link);
					} else if (s.endsWith(":duelreq:")) {
						String s4 = s.substring(0, s.indexOf(":"));
						long l18 = TextUtil.longForName(s4);
						boolean flag3 = false;
						for (int k27 = 0; k27 < ignoreCount; k27++) {
							if (ignoreListAsLongs[k27] != l18) {
								continue;
							}
							flag3 = true;
						}
						if (!flag3 && (anInt1251 == 0)) {
							pushMessage("wishes to duel with you.", 8, s4);
						}
					} else if (s.endsWith(":chalreq:")) {
						String s5 = s.substring(0, s.indexOf(":"));
						long l19 = TextUtil.longForName(s5);
						boolean flag4 = false;
						for (int l27 = 0; l27 < ignoreCount; l27++) {
							if (ignoreListAsLongs[l27] != l19) {
								continue;
							}
							flag4 = true;
						}
						if (!flag4 && (anInt1251 == 0)) {
							String s8 = s.substring(s.indexOf(":") + 1, s.length() - 9);
							pushMessage(s8, 8, s5);
						}
					} else {
						pushMessage(s, 0, "");
					}
					packetType = -1;
					return true;
				case 1:
					for (int k4 = 0; k4 < playerArray.length; k4++) {
						if (playerArray[k4] != null) {
							playerArray[k4].currentAnimation = -1;
						}
					}
					for (int j12 = 0; j12 < npcArray.length; j12++) {
						if (npcArray[j12] != null) {
							npcArray[j12].currentAnimation = -1;
						}
					}
					packetType = -1;
					return true;
				case 50:
					long l4 = inputStream.getLong();
					int i18 = inputStream.getUnsignedByte();
					String s7 = TextUtil.fixName(TextUtil.nameForLong(l4));
					for (int k24 = 0; k24 < friendsCount; k24++) {
						if (l4 != friendsListAsLongs[k24]) {
							continue;
						}
						if (friendsNodeIDs[k24] != i18) {
							friendsNodeIDs[k24] = i18;
							drawInventoryRequest = true;
							if (i18 >= 2) {
								pushMessage(s7 + " has logged in.", 5, "");
							}
							if (i18 <= 1) {
								pushMessage(s7 + " has logged out.", 5, "");
							}
						}
						s7 = null;
					}
					if ((s7 != null) && (friendsCount < 200)) {
						friendsListAsLongs[friendsCount] = l4;
						friendsList[friendsCount] = s7;
						friendsNodeIDs[friendsCount] = i18;
						friendsCount++;
						drawInventoryRequest = true;
					}
					for (boolean flag6 = false; !flag6;) {
						flag6 = true;
						for (int k29 = 0; k29 < friendsCount - 1; k29++) {
							if (((friendsNodeIDs[k29] != Client.nodeID) && (friendsNodeIDs[k29 + 1] == Client.nodeID))
							|| ((friendsNodeIDs[k29] == 0) && (friendsNodeIDs[k29 + 1] != 0))) {
								int j31 = friendsNodeIDs[k29];
								friendsNodeIDs[k29] = friendsNodeIDs[k29 + 1];
								friendsNodeIDs[k29 + 1] = j31;
								String s10 = friendsList[k29];
								friendsList[k29] = friendsList[k29 + 1];
								friendsList[k29 + 1] = s10;
								long l32 = friendsListAsLongs[k29];
								friendsListAsLongs[k29] = friendsListAsLongs[k29 + 1];
								friendsListAsLongs[k29 + 1] = l32;
								drawInventoryRequest = true;
								flag6 = false;
							}
						}
					}
					packetType = -1;
					return true;
				case 110:
					if (tabID == 12) {
						drawInventoryRequest = true;
					}
					playerEnergy = inputStream.getUnsignedByte();
					packetType = -1;
					return true;
				case 254:
					anInt855 = inputStream.getUnsignedByte();
					if (anInt855 == 1) {
						anInt1222 = inputStream.getUnsignedShort();
					}
					if ((anInt855 >= 2) && (anInt855 <= 6)) {
						if (anInt855 == 2) {
							anInt937 = 64;
							anInt938 = 64;
						}
						if (anInt855 == 3) {
							anInt937 = 0;
							anInt938 = 64;
						}
						if (anInt855 == 4) {
							anInt937 = 128;
							anInt938 = 64;
						}
						if (anInt855 == 5) {
							anInt937 = 64;
							anInt938 = 0;
						}
						if (anInt855 == 6) {
							anInt937 = 64;
							anInt938 = 128;
						}
						anInt855 = 2;
						anInt934 = inputStream.getUnsignedShort();
						anInt935 = inputStream.getUnsignedShort();
						anInt936 = inputStream.getUnsignedByte();
					}
					if (anInt855 == 10) {
						anInt933 = inputStream.getUnsignedShort();
					}
					packetType = -1;
					return true;
				case 248:
					int i5 = inputStream.getUnsignedLEShortA();
					int k12 = inputStream.getUnsignedShort();
					if (backDialogID != -1) {
						backDialogID = -1;
						Client.inputTaken = true;
					}
					if (inputDialogState != 0) {
						inputDialogState = 0;
						Client.inputTaken = true;
					}
					openInterfaceID = i5;
					invOverlayInterfaceID = k12;
					drawInventoryRequest = true;
					inventoryAltered = true;
					aBoolean1149 = false;
					packetType = -1;
					return true;
				case 79:
					int j5 = inputStream.getUnsignedLEShort();
					int l12 = inputStream.getUnsignedLEShortA();
					Interface iComponent_3 = Interface.interfaceCache[j5];
					if ((iComponent_3 != null) && (iComponent_3.type == 0)) {
						if (l12 < 0) {
							l12 = 0;
						}
						if (l12 > iComponent_3.scrollMax - iComponent_3.height) {
							l12 = iComponent_3.scrollMax - iComponent_3.height;
						}
						iComponent_3.scrollPosition = l12;
					}
					packetType = -1;
					return true;
				case 68:
					for (int k5 = 0; k5 < variousSettings.length; k5++) {
						if (variousSettings[k5] != anIntArray1045[k5]) {
							variousSettings[k5] = anIntArray1045[k5];
							processClientOptions(k5);
							drawInventoryRequest = true;
						}
					}
					packetType = -1;
					return true;
				case 196:
					long l5 = inputStream.getLong();
					int j18 = inputStream.getInt();
					int l21 = inputStream.getUnsignedByte();
					boolean flag5 = false;
					for (int i28 = 0; i28 < 100; i28++) {
						if (anIntArray1240[i28] != j18) {
							continue;
						}
						flag5 = true;
					}
					if (l21 <= 1) {
						for (int l29 = 0; l29 < ignoreCount; l29++) {
							if (ignoreListAsLongs[l29] != l5) {
								continue;
							}
							flag5 = true;
						}
					}
					if (!flag5 && (anInt1251 == 0)) {
						try {
							anIntArray1240[anInt1169] = j18;
							anInt1169 = (anInt1169 + 1) % 100;
							String s9 = ChatInput.method525(packetSize - 13, inputStream);
							if (l21 != 3) {
								// s9 = Censor.doCensor(s9);
								if ((l21 == 2) || (l21 == 3)) {
									pushMessage(s9, 7, "@cr2@"
									+ TextUtil.fixName(TextUtil.nameForLong(l5)));
								} else if (l21 == 1) {
									pushMessage(s9, 7, "@cr1@"
									+ TextUtil.fixName(TextUtil.nameForLong(l5)));
								} else {
									pushMessage(s9, 3, TextUtil.fixName(TextUtil.nameForLong(l5)));
								}
							}
						} catch (Exception exception1) {
							Signlink.reporterror("cde1");
						}
					}
					packetType = -1;
					return true;
				case 85:
					anInt1269 = inputStream.getUnsignedByteC();
					anInt1268 = inputStream.getUnsignedByteC();
					packetType = -1;
					return true;
				case 24:
					anInt1054 = inputStream.getUnsignedByteS();
					if (anInt1054 == tabID) {
						if (anInt1054 == 3) {
							tabID = 1;
						} else {
							tabID = 3;
						}
						drawInventoryRequest = true;
					}
					packetType = -1;
					return true;
				case 246:
					int i6 = inputStream.getUnsignedLEShort();
					int i13 = inputStream.getUnsignedShort();
					int k18 = inputStream.getUnsignedShort();
					if (k18 == 65535) {
						Interface.interfaceCache[i6].anInt233 = 0;
						packetType = -1;
						return true;
					} else {
						ItemDefinition itemDefinition = ItemDefinition.forID(k18);
						Interface.interfaceCache[i6].anInt233 = 4;
						Interface.interfaceCache[i6].mediaID = k18;
						Interface.interfaceCache[i6].modelRotation1 = itemDefinition.rotationY;
						Interface.interfaceCache[i6].modelRotation2 = itemDefinition.rotationX;
						Interface.interfaceCache[i6].modelZoom = (itemDefinition.zoom * 100) / i13;
						packetType = -1;
						return true;
					}
				case 171:
					boolean flag1 = inputStream.getUnsignedByte() == 1;
					int j13 = inputStream.getUnsignedShort();
					Interface.interfaceCache[j13].hoverable = flag1;
					packetType = -1;
					return true;
				case 142:
					int j6 = inputStream.getUnsignedLEShort();
					method60(j6);
					if (backDialogID != -1) {
						backDialogID = -1;
						Client.inputTaken = true;
					}
					if (inputDialogState != 0) {
						inputDialogState = 0;
						Client.inputTaken = true;
					}
					invOverlayInterfaceID = j6;
					drawInventoryRequest = true;
					inventoryAltered = true;
					openInterfaceID = -1;
					aBoolean1149 = false;
					packetType = -1;
					return true;
				case 126:
					String text = inputStream.getString();
					int frame = inputStream.getUnsignedLEShortA();
					updateStrings(text, frame);
					sendFrame126(text, frame);
					packetType = -1;
					return true;
				case 206:
					publicChatMode = inputStream.getUnsignedByte();
					privateChatMode = inputStream.getUnsignedByte();
					tradeMode = inputStream.getUnsignedByte();
					Client.inputTaken = true;
					packetType = -1;
					return true;
				case 240:
					if (tabID == 12) {
						drawInventoryRequest = true;
					}
					weight = inputStream.getShort();
					packetType = -1;
					return true;
				case 8:
					int k6 = inputStream.getUnsignedShortA();
					int l13 = inputStream.getUnsignedShort();
					Interface.interfaceCache[k6].anInt233 = 1;
					Interface.interfaceCache[k6].mediaID = l13;
					packetType = -1;
					return true;
				case 122:
					int l6 = inputStream.getUnsignedShortA();
					int i14 = inputStream.getUnsignedShortA();
					int i19 = i14 >> 10 & 0x1f;
					int i22 = i14 >> 5 & 0x1f;
					int l24 = i14 & 0x1f;
					Interface.interfaceCache[l6].textColor = (i19 << 19) + (i22 << 11)
					+ (l24 << 3);
					packetType = -1;
					return true;
				case 53:
					drawInventoryRequest = true;
					int i7 = inputStream.getUnsignedShort();
					Interface inventoryInterface_1 = Interface.interfaceCache[i7];
					int j19 = inputStream.getUnsignedShort();
					for (int j22 = 0; j22 < j19; j22++) {
						int i25 = inputStream.getUnsignedByte();
						if (i25 == 255) {
							i25 = inputStream.getInt1();
						}
						inventoryInterface_1.inv[j22] = inputStream.getUnsignedShortA();
						inventoryInterface_1.invStackSizes[j22] = i25;
					}
					for (int j25 = j19; j25 < inventoryInterface_1.inv.length; j25++) {
						inventoryInterface_1.inv[j25] = 0;
						inventoryInterface_1.invStackSizes[j25] = 0;
					}
					packetType = -1;
					return true;
				case 230:
					int j7 = inputStream.getUnsignedLEShortA();
					int j14 = inputStream.getUnsignedShort();
					int k19 = inputStream.getUnsignedShort();
					int k22 = inputStream.getUnsignedShortA();
					Interface.interfaceCache[j14].modelRotation1 = k19;
					Interface.interfaceCache[j14].modelRotation2 = k22;
					Interface.interfaceCache[j14].modelZoom = j7;
					packetType = -1;
					return true;
				case 221:
					anInt900 = inputStream.getUnsignedByte();
					drawInventoryRequest = true;
					packetType = -1;
					return true;
				case 177:
					aBoolean1160 = true;
					anInt995 = inputStream.getUnsignedByte();
					anInt996 = inputStream.getUnsignedByte();
					anInt997 = inputStream.getUnsignedShort();
					anInt998 = inputStream.getUnsignedByte();
					anInt999 = inputStream.getUnsignedByte();
					if (anInt999 >= 100) {
						int k7 = anInt995 * 128 + 64;
						int k14 = anInt996 * 128 + 64;
						int i20 = getEntityHeightOffset(plane, k14, k7) - anInt997;
						int l22 = k7 - xCameraPos;
						int k25 = i20 - zCameraPos;
						int j28 = k14 - yCameraPos;
						int i30 = (int) Math.sqrt(l22 * l22 + j28 * j28);
						cameraPitch = (int) (Math.atan2(k25, i30) * 325.94900000000001D) & 0x7ff;
						cameraYaw = (int) (Math.atan2(l22, j28) * -325.94900000000001D) & 0x7ff;
						if (cameraPitch < 128) {
							cameraPitch = 128;
						}
						if (cameraPitch > 383) {
							cameraPitch = 383;
						}
					}
					packetType = -1;
					return true;
				case 249:
					anInt1046 = inputStream.getUnsignedByteA();
					unknownInt10 = inputStream.getUnsignedShortA();
					packetType = -1;
					return true;
				case 65:
					updateNPCs(inputStream, packetSize);
					packetType = -1;
					return true;
				case 27:
					messagePromptRaised = false;
					inputDialogState = 1;
					amountOrNameInput = "";
					Client.inputTaken = true;
					packetType = -1;
					return true;
				case 187:
					messagePromptRaised = false;
					inputDialogState = 2;
					amountOrNameInput = "";
					Client.inputTaken = true;
					packetType = -1;
					return true;
				case 97:
					int l7 = inputStream.getUnsignedShort();
					method60(l7);
					if (invOverlayInterfaceID != -1) {
						invOverlayInterfaceID = -1;
						drawInventoryRequest = true;
						inventoryAltered = true;
					}
					if (backDialogID != -1) {
						backDialogID = -1;
						Client.inputTaken = true;
					}
					if (inputDialogState != 0) {
						inputDialogState = 0;
						Client.inputTaken = true;
					}
					openInterfaceID = l7;
					aBoolean1149 = false;
					packetType = -1;
					return true;
				case 218:
					int i8 = inputStream.getLEShortA();
					dialogID = i8;
					Client.inputTaken = true;
					packetType = -1;
					return true;
				case 87:
					int j8 = inputStream.getUnsignedLEShort();
					int l14 = inputStream.getInt2();
					anIntArray1045[j8] = l14;
					if (variousSettings[j8] != l14) {
						variousSettings[j8] = l14;
						processClientOptions(j8);
						drawInventoryRequest = true;
						if (dialogID != -1) {
							Client.inputTaken = true;
						}
					}
					packetType = -1;
					return true;
				case 36:
					int k8 = inputStream.getUnsignedLEShort();
					byte byte0 = inputStream.getByte();
					anIntArray1045[k8] = byte0;
					if (variousSettings[k8] != byte0) {
						variousSettings[k8] = byte0;
						processClientOptions(k8);
						drawInventoryRequest = true;
						if (dialogID != -1) {
							Client.inputTaken = true;
						}
					}
					packetType = -1;
					return true;
				case 61:
					anInt1055 = inputStream.getUnsignedByte();
					packetType = -1;
					return true;
				case 200:
					int l8 = inputStream.getUnsignedShort();
					int i15 = inputStream.getShort();
					Interface iComponent_4 = Interface.interfaceCache[l8];
					iComponent_4.anInt257 = i15;
					if (i15 == -1) {
						iComponent_4.anInt246 = 0;
						iComponent_4.anInt208 = 0;
					}
					packetType = -1;
					return true;
				case 219:
					if (invOverlayInterfaceID != -1) {
						invOverlayInterfaceID = -1;
						drawInventoryRequest = true;
						inventoryAltered = true;
					}
					if (backDialogID != -1) {
						backDialogID = -1;
						Client.inputTaken = true;
					}
					if (inputDialogState != 0) {
						inputDialogState = 0;
						Client.inputTaken = true;
					}
					openInterfaceID = -1;
					aBoolean1149 = false;
					packetType = -1;
					return true;
				case 34:
					drawInventoryRequest = true;
					int i9 = inputStream.getUnsignedShort();
					Interface inventoryInterface_2 = Interface.interfaceCache[i9];
					while (inputStream.offset < packetSize) {
						int j20 = inputStream.getSmart();
						int i23 = inputStream.getUnsignedShort();
						int l25 = inputStream.getUnsignedByte();
						if (l25 == 255) {
							l25 = inputStream.getInt();
						}
						if ((j20 >= 0) && (j20 < inventoryInterface_2.inv.length)) {
							inventoryInterface_2.inv[j20] = i23;
							inventoryInterface_2.invStackSizes[j20] = l25;
						}
					}
					packetType = -1;
					return true;
				case 4:
				case 44:
				case 84:
				case 101:
				case 105:
				case 117:
				case 147:
				case 151:
				case 156:
				case 160:
				case 215:
					method137(inputStream, packetType);
					packetType = -1;
					return true;
				case 106:
					tabID = inputStream.getUnsignedByteC();
					drawInventoryRequest = true;
					inventoryAltered = true;
					packetType = -1;
					return true;
				case 164:
					int j9 = inputStream.getUnsignedLEShort();
					method60(j9);
					if (invOverlayInterfaceID != -1) {
						invOverlayInterfaceID = -1;
						drawInventoryRequest = true;
						inventoryAltered = true;
					}
					backDialogID = j9;
					Client.inputTaken = true;
					openInterfaceID = -1;
					aBoolean1149 = false;
					packetType = -1;
					return true;
			}
			Signlink.reporterror("T1 - " + packetType + "," + packetSize + " - " + anInt842 + ","
			+ anInt843);
			resetLogout();
		} catch (IOException _ex) {
			dropClient();
		} catch (Exception exception) {
			String s2 = "T2 - " + packetType + "," + anInt842 + "," + anInt843 + " - " + packetSize
			+ "," + (baseX + Client.myPlayer.walkQueueX[0]) + ","
			+ (baseY + Client.myPlayer.walkQueueY[0]) + " - ";
			for (int j15 = 0; (j15 < packetSize) && (j15 < 50); j15++) {
				s2 = s2 + inputStream.buffer[j15] + ",";
			}
			Signlink.reporterror(s2);
			resetLogout();
		}
		return true;
	}

	public void preloadModels() {
		File file = new File("./models/raw/");
		File[] fileArray = file.listFiles();
		for (File element : fileArray) {
			String s = element.getName();
			byte[] buffer = Client.readFile("./models/raw/" + s);
			Model.method460(buffer, Integer.parseInt(Client.getFileNameWithoutExtension(s)));
		}
	}

	private void printDebug() {
		System.out.println("============");
		System.out.println("flame-cycle:" + anInt1208);
		if (onDemandFetcher != null) {
			System.out.println("Od-cycle:" + onDemandFetcher.onDemandCycle);
		}
		System.out.println("loop-cycle:" + Client.loopCycle);
		System.out.println("draw-cycle:" + Client.anInt1061);
		System.out.println("ptype:" + packetType);
		System.out.println("psize:" + packetSize);
		if (socketStream != null) {
			socketStream.printDebug();
		}
		super.shouldDebug = true;
	}

	@Override
	public void processDrawing() {
		if (rsAlreadyLoaded || loadingError || genericLoadingError) {
			showErrorScreen();
			return;
		}
		Client.anInt1061++;
		if (!Client.loggedIn) {
			drawTitlebox(false);
		} else {
			drawGameScreen();
		}
		anInt1213 = 0;
	}

	@Override
	public void processGameLoop() {
		if (rsAlreadyLoaded || loadingError || genericLoadingError) {
			return;
		}
		Client.loopCycle++;
		if (!Client.loggedIn) {
			processLoginScreenInput();
		} else {
			mainGameProcessor();
		}
		processOnDemandQueue();
	}

	private void processLoginScreenInput() {
		if (loginScreenState == 0) {
			int i = super.width / 2 - 80;
			int l = super.height / 2 + 20;
			l += 20;
			if ((super.clickMode3 == 1) && (super.saveClickX >= i - 75)
			&& (super.saveClickX <= i + 75) && (super.saveClickY >= l - 20)
			&& (super.saveClickY <= l + 20)) {
				loginScreenState = 3;
				loginScreenCursorPos = 0;
			}
			i = super.width / 2 + 80;
			if ((super.clickMode3 == 1) && (super.saveClickX >= i - 75)
			&& (super.saveClickX <= i + 75) && (super.saveClickY >= l - 20)
			&& (super.saveClickY <= l + 20)) {
				loginMessage1 = "";
				loginMessage2 = "Enter your username & password.";
				loginScreenState = 2;
				loginScreenCursorPos = 0;
			}
		} else {
			if (loginScreenState == 2) {
				int j = super.height / 2 - 40;
				j += 30;
				j += 25;
				if ((super.clickMode3 == 1) && (super.saveClickY >= j - 15)
				&& (super.saveClickY < j)) {
					loginScreenCursorPos = 0;
				}
				j += 15;
				if ((super.clickMode3 == 1) && (super.saveClickY >= j - 15)
				&& (super.saveClickY < j)) {
					loginScreenCursorPos = 1;
				}
				j += 15;
				int i1 = super.width / 2 - 80;
				int k1 = super.height / 2 + 50;
				k1 += 20;
				if ((super.clickMode3 == 1) && (super.saveClickX >= i1 - 75)
				&& (super.saveClickX <= i1 + 75) && (super.saveClickY >= k1 - 20)
				&& (super.saveClickY <= k1 + 20)) {
					loginFailures = 0;
					login(myUsername, myPassword, false);
					if (Client.loggedIn) {
						return;
					}
				}
				i1 = super.width / 2 + 80;
				if ((super.clickMode3 == 1) && (super.saveClickX >= i1 - 75)
				&& (super.saveClickX <= i1 + 75) && (super.saveClickY >= k1 - 20)
				&& (super.saveClickY <= k1 + 20)) {
					loginScreenState = 0;
					// myUsername = "";
					// myPassword = "";
				}
				do {
					int l1 = readChar(-796);
					if (l1 == -1) {
						break;
					}
					boolean flag1 = false;
					for (int i2 = 0; i2 < Client.validUserPassChars.length(); i2++) {
						if (l1 != Client.validUserPassChars.charAt(i2)) {
							continue;
						}
						flag1 = true;
						break;
					}
					if (loginScreenCursorPos == 0) {
						if ((l1 == 8) && (myUsername.length() > 0)) {
							myUsername = myUsername.substring(0, myUsername.length() - 1);
						}
						if ((l1 == 9) || (l1 == 10) || (l1 == 13)) {
							loginScreenCursorPos = 1;
						}
						if (flag1) {
							myUsername += (char) l1;
						}
						if (myUsername.length() > 12) {
							myUsername = myUsername.substring(0, 12);
						}
					} else if (loginScreenCursorPos == 1) {
						if ((l1 == 8) && (myPassword.length() > 0)) {
							myPassword = myPassword.substring(0, myPassword.length() - 1);
						}
						if ((l1 == 9) || (l1 == 10) || (l1 == 13)) {
							loginScreenCursorPos = 0;
						}
						if (flag1) {
							myPassword += (char) l1;
						}
						if (myPassword.length() > 20) {
							myPassword = myPassword.substring(0, 20);
						}
					}
				} while (true);
				return;
			}
			if (loginScreenState == 3) {
				int k = super.width / 2;
				int j1 = super.height / 2 + 50;
				j1 += 20;
				if ((super.clickMode3 == 1) && (super.saveClickX >= k - 75)
				&& (super.saveClickX <= k + 75) && (super.saveClickY >= j1 - 20)
				&& (super.saveClickY <= j1 + 20)) {
					loginScreenState = 0;
				}
			}
		}
	}

	private void processMainScreenClick() {
		if (anInt1021 != 0) {
			return;
		}
		if (super.clickMode3 == 1) {
			int x, y, leftX = 0, bottomY = 0, topX = 0;
			if (VERSION > 474) {
				x = super.saveClickX - 558;
				y = super.saveClickY - 8;
				leftX = -8;
				topX = 0;
				bottomY = 152;
			} else {
				x = super.saveClickX - 569;
				y = super.saveClickY - 6;
				leftX = 0;
				topX = 2;
				bottomY = 153;
			}
			if ((x >= leftX) && (y >= topX) && (x < 144) && (y < bottomY)) {
				x -= 73;
				y -= 75;
				int k = minimapAndCompassRotation + minimapRotation & 0x7ff;
				int i1 = Renderer3D.sineTable[k];
				int j1 = Renderer3D.cosineTable[k];
				i1 = i1 * (minimapZoom + 256) >> 8;
				j1 = j1 * (minimapZoom + 256) >> 8;
				int k1 = y * i1 + x * j1 >> 11;
				int l1 = y * j1 - x * i1 >> 11;
				int i2 = Client.myPlayer.x + k1 >> 7;
				int j2 = Client.myPlayer.y - l1 >> 7;
				boolean flag = doWalkTo(1, 0, 0, 0, Client.myPlayer.walkQueueY[0], 0, 0, j2,
				Client.myPlayer.walkQueueX[0], true, i2);
				if (flag) {
					outputStream.putByte(x);
					outputStream.putByte(y);
					outputStream.putShort(minimapAndCompassRotation);
					outputStream.putByte(57);
					outputStream.putByte(minimapRotation);
					outputStream.putByte(minimapZoom);
					outputStream.putByte(89);
					outputStream.putShort(Client.myPlayer.x);
					outputStream.putShort(Client.myPlayer.y);
					outputStream.putByte(anInt1264);
					outputStream.putByte(63);
				}
			}
			Client.anInt1117++;
			if (Client.anInt1117 > 1151) {
				Client.anInt1117 = 0;
				outputStream.putOperation(246);
				outputStream.putByte(0);
				int l = outputStream.offset;
				if ((int) (Math.random() * 2D) == 0) {
					outputStream.putByte(101);
				}
				outputStream.putByte(197);
				outputStream.putShort((int) (Math.random() * 65536D));
				outputStream.putByte((int) (Math.random() * 256D));
				outputStream.putByte(67);
				outputStream.putShort(14314);
				if ((int) (Math.random() * 2D) == 0) {
					outputStream.putShort(29487);
				}
				outputStream.putShort((int) (Math.random() * 65536D));
				if ((int) (Math.random() * 2D) == 0) {
					outputStream.putByte(220);
				}
				outputStream.putByte(180);
				outputStream.putByte(outputStream.offset - l);
			}
		}
	}

	private boolean processMenuClick() {
		if (activeInterfaceType != 0) {
			return false;
		}
		int j = super.clickMode3;
		if ((spellSelected == 1) && (super.saveClickX >= 516) && (super.saveClickY >= 160)
		&& (super.saveClickX <= 765) && (super.saveClickY <= 205)) {
			j = 0;
		}
		if (menuOpen) {
			if (j != 1) {
				int x = super.mouseX;
				int y = super.mouseY;
				if ((x < menuOffsetX - 10) || (x > menuOffsetX + menuWidth + 10)
				|| (y < menuOffsetY - 10) || (y > menuOffsetY + menuHeight + 10)) {
					menuOpen = false;
					drawInventoryRequest = true;
					inputTaken = true;
				}
			}
			if (j == 1) {
				int x = menuOffsetX;
				int y = menuOffsetY;
				int width = menuWidth;
				int clickX = super.saveClickX;
				int clickY = super.saveClickY;
				int actionID = -1;
				for (int loopID = 0; loopID < menuActionRow; loopID++) {
					int k3 = y + 31 + (menuActionRow - 1 - loopID) * 15;
					if ((clickX > x) && (clickX < x + width) && (clickY > k3 - 13)
					&& (clickY < k3 + 3)) {
						actionID = loopID;
					}
				}
				if (actionID != -1) {
					doAction(actionID);
				}
				menuOpen = false;
				drawInventoryRequest = true;
				Client.inputTaken = true;
			}
			return true;
		} else {
			if ((j == 1) && (menuActionRow > 0)) {
				int i1 = menuActionID[menuActionRow - 1];
				if ((i1 == 632) || (i1 == 78) || (i1 == 867) || (i1 == 431) || (i1 == 53)
				|| (i1 == 74) || (i1 == 454) || (i1 == 539) || (i1 == 493) || (i1 == 847)
				|| (i1 == 447) || (i1 == 1125)) {
					int l1 = menuActionCmd2[menuActionRow - 1];
					int j2 = menuActionCmd3[menuActionRow - 1];
					Interface menuInterface = Interface.interfaceCache[j2];
					if (menuInterface.aBoolean259 || menuInterface.aBoolean235) {
						aBoolean1242 = false;
						anInt989 = 0;
						anInt1084 = j2;
						anInt1085 = l1;
						activeInterfaceType = 2;
						anInt1087 = super.saveClickX;
						anInt1088 = super.saveClickY;
						if (Interface.interfaceCache[j2].parentID == openInterfaceID) {
							activeInterfaceType = 1;
						}
						if (Interface.interfaceCache[j2].parentID == backDialogID) {
							activeInterfaceType = 3;
						}
						return true;
					}
				}
			}
			if ((j == 1) && ((anInt1253 == 1) || menuHasAddFriend(menuActionRow - 1))
			&& (menuActionRow > 2)) {
				j = 2;
			}
			if ((j == 1) && (menuActionRow > 0)) {
				doAction(menuActionRow - 1);
			}
			if ((j == 2) && (menuActionRow > 0)) {
				determineMenuSize();
			}
			return false;
		}
	}

	private void processOnDemandQueue() {
		do {
			OnDemandData onDemandData;
			do {
				onDemandData = onDemandFetcher.getNextNode();
				if (onDemandData == null) {
					return;
				}
				if (onDemandData.dataType == 0) {
					Model.method460(onDemandData.buffer, onDemandData.ID);
					if ((onDemandFetcher.getModelIndex(onDemandData.ID) & 0x62) != 0) {
						drawInventoryRequest = true;
						if (backDialogID != -1) {
							Client.inputTaken = true;
						}
					}
				}
				if ((onDemandData.dataType == 1) && (onDemandData.buffer != null)) {
					FrameReader.readValues(onDemandData.buffer);
				}
				if ((onDemandData.dataType == 2) && (onDemandData.ID == nextSong)
				&& (onDemandData.buffer != null)) {
					saveMidi(songChanging, onDemandData.buffer);
				}
				if ((onDemandData.dataType == 3) && (loadingStage == 1)) {
					for (int i = 0; i < aByteArrayArray1183.length; i++) {
						if (anIntArray1235[i] == onDemandData.ID) {
							aByteArrayArray1183[i] = onDemandData.buffer;
							if (onDemandData.buffer == null) {
								anIntArray1235[i] = -1;
							}
							break;
						}
						if (anIntArray1236[i] != onDemandData.ID) {
							continue;
						}
						aByteArrayArray1247[i] = onDemandData.buffer;
						if (onDemandData.buffer == null) {
							anIntArray1236[i] = -1;
						}
						break;
					}
				}
			} while ((onDemandData.dataType != 93) || !onDemandFetcher.method564(onDemandData.ID));
			Region.method173(new Packet(onDemandData.buffer), onDemandFetcher);
		} while (true);
	}

	public void processRightClick() {
		if (activeInterfaceType != 0) {
			return;
		}
		menuActionName[0] = "Cancel";
		menuActionID[0] = 1107;
		menuActionRow = 1;
		if (fullscreenInterfaceID != -1) {
			anInt886 = 0;
			anInt1315 = 0;
			buildInterfaceMenu(8, Interface.interfaceCache[fullscreenInterfaceID], super.mouseX,
			8, super.mouseY, 0);
			if (anInt886 != anInt1026) {
				anInt1026 = anInt886;
			}
			if (anInt1315 != anInt1129) {
				anInt1129 = anInt1315;
			}
			return;
		}
		buildSplitPrivateChatMenu();
		processFilterButtonClick();
		processMinimapClick();
		anInt886 = 0;
		anInt1315 = 0;
		// Game area
		if ((super.mouseX > 0) && (super.mouseY > 0) && (super.mouseX < 516)
		&& (super.mouseY < 338)) {
			if (openInterfaceID != -1) {
				buildInterfaceMenu(4, Interface.interfaceCache[openInterfaceID], super.mouseX, 4,
				super.mouseY, 0);
			} else {
				build3dScreenMenu();
			}
		}
		if (anInt886 != anInt1026) {
			anInt1026 = anInt886;
		}
		if (anInt1315 != anInt1129) {
			anInt1129 = anInt1315;
		}
		anInt886 = 0;
		anInt1315 = 0;
		// Tab area
		if ((super.mouseX >= 547) && (super.mouseY >= 205) && (super.mouseX <= 736)
		&& (super.mouseY <= 465)) {
			if (invOverlayInterfaceID != -1) {
				buildInterfaceMenu(547, Interface.interfaceCache[invOverlayInterfaceID],
				super.mouseX, 205, super.mouseY, 0);
			} else if (tabInterfaceIDs[tabID] != -1) {
				buildInterfaceMenu(547, Interface.interfaceCache[tabInterfaceIDs[tabID]],
				super.mouseX, 205, super.mouseY, 0);
			}
		}
		if (anInt886 != anInt1048) {
			drawInventoryRequest = true;
			inventoryAltered = true;
			anInt1048 = anInt886;
		}
		if (anInt1315 != anInt1044) {
			drawInventoryRequest = true;
			inventoryAltered = true;
			anInt1044 = anInt1315;
		}
		anInt886 = 0;
		anInt1315 = 0;
		// Chat area
		if ((super.mouseX >= 0) && (super.mouseY >= 338) && (super.mouseX <= 515)
		&& (super.mouseY <= 503)) {
			if (backDialogID != -1) {
				buildInterfaceMenu(0, Interface.interfaceCache[backDialogID], super.mouseX, 361,
				super.mouseY, 0);
			} else if ((super.mouseY < 503) && (super.mouseX < 516)) {
				buildChatboxMenu(super.mouseY - 361);
			}
		}
		if ((backDialogID != -1) && (anInt886 != anInt1039)) {
			Client.inputTaken = true;
			anInt1039 = anInt886;
		}
		if ((backDialogID != -1) && (anInt1315 != anInt1500)) {
			Client.inputTaken = true;
			anInt1500 = anInt1315;
		}
		boolean flag = false;
		while (!flag) {
			flag = true;
			for (int j = 0; j < menuActionRow - 1; j++) {
				if ((menuActionID[j] < 1000) && (menuActionID[j + 1] > 1000)) {
					String s = menuActionName[j];
					menuActionName[j] = menuActionName[j + 1];
					menuActionName[j + 1] = s;
					int k = menuActionID[j];
					menuActionID[j] = menuActionID[j + 1];
					menuActionID[j + 1] = k;
					k = menuActionCmd2[j];
					menuActionCmd2[j] = menuActionCmd2[j + 1];
					menuActionCmd2[j + 1] = k;
					k = menuActionCmd3[j];
					menuActionCmd3[j] = menuActionCmd3[j + 1];
					menuActionCmd3[j + 1] = k;
					k = menuActionCmd1[j];
					menuActionCmd1[j] = menuActionCmd1[j + 1];
					menuActionCmd1[j + 1] = k;
					flag = false;
				}
			}
		}
	}

	private void processTabClick() {
		if (VERSION > 508) {
			if ((super.saveClickX >= 523) && (super.saveClickX <= 551) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[0] != -1)) {
				drawInventoryRequest = true;
				tabID = 0;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 552) && (super.saveClickX <= 581) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[1] != -1)) {
				drawInventoryRequest = true;
				tabID = 1;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 582) && (super.saveClickX <= 611) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[2] != -1)) {
				drawInventoryRequest = true;
				tabID = 2;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 612) && (super.saveClickX <= 641) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[15] != -1)) {
				drawInventoryRequest = true;
				tabID = 14;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 642) && (super.saveClickX <= 671) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[3] != -1)) {
				drawInventoryRequest = true;
				tabID = 3;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 672) && (super.saveClickX <= 701) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[4] != -1)) {
				drawInventoryRequest = true;
				tabID = 4;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 702) && (super.saveClickX <= 731) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[5] != -1)) {
				drawInventoryRequest = true;
				tabID = 5;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 732) && (super.saveClickX <= 761) && (super.saveClickY >= 169)
			&& (super.saveClickY <= 202) && (tabInterfaceIDs[6] != -1)) {
				drawInventoryRequest = true;
				tabID = 6;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 523) && (super.saveClickX <= 553) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[14] != -1)) {
				drawInventoryRequest = true;
				tabID = 13;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 552) && (super.saveClickX <= 581) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[8] != -1)) {
				drawInventoryRequest = true;
				tabID = 8;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 582) && (super.saveClickX <= 611) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[9] != -1)) {
				drawInventoryRequest = true;
				tabID = 9;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 612) && (super.saveClickX <= 641) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[7] != -1)) {
				drawInventoryRequest = true;
				tabID = 7;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 744) && (super.saveClickX <= 764) && (super.saveClickY >= 0)
			&& (super.saveClickY <= 20) && (tabInterfaceIDs[10] != -1)) {
				tabID = 10;
			}
			if ((super.saveClickX >= 642) && (super.saveClickX <= 671) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[11] != -1)) {
				drawInventoryRequest = true;
				tabID = 11;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 672) && (super.saveClickX <= 701) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[12] != -1)) {
				drawInventoryRequest = true;
				tabID = 12;
				inventoryAltered = true;
			}
			if ((super.saveClickX >= 702) && (super.saveClickX <= 731) && (super.saveClickY >= 467)
			&& (super.saveClickY <= 501) && (tabInterfaceIDs[13] != -1)) {
				drawInventoryRequest = true;
				tabID = 13;
				inventoryAltered = true;
			}
			if ((super.mouseX >= 523) && (super.mouseX <= 551) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[0] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 0;
				inventoryAltered = true;
			} else if ((super.mouseX >= 552) && (super.mouseX <= 581) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[1] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 1;
				inventoryAltered = true;
			} else if ((super.mouseX >= 582) && (super.mouseX <= 611) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[2] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 2;
				inventoryAltered = true;
			} else if ((super.mouseX >= 612) && (super.mouseX <= 641) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[15] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 14;
				inventoryAltered = true;
			} else if ((super.mouseX >= 642) && (super.mouseX <= 671) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[3] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 3;
				inventoryAltered = true;
			} else if ((super.mouseX >= 672) && (super.mouseX <= 701) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[4] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 4;
				inventoryAltered = true;
			} else if ((super.mouseX >= 702) && (super.mouseX <= 731) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[5] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 5;
				inventoryAltered = true;
			} else if ((super.mouseX >= 732) && (super.mouseX <= 761) && (super.mouseY >= 169)
			&& (super.mouseY <= 202) && (tabInterfaceIDs[6] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 6;
				inventoryAltered = true;
			} else if ((super.mouseX >= 523) && (super.mouseX <= 553) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[14] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 13;
				inventoryAltered = true;
			} else if ((super.mouseX >= 552) && (super.mouseX <= 581) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[8] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 8;
				inventoryAltered = true;
			} else if ((super.mouseX >= 582) && (super.mouseX <= 611) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[9] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 9;
				inventoryAltered = true;
			} else if ((super.mouseX >= 612) && (super.mouseX <= 641) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[7] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 7;
				inventoryAltered = true;
			} else if ((super.mouseX >= 642) && (super.mouseX <= 671) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[11] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 11;
				inventoryAltered = true;
			} else if ((super.mouseX >= 672) && (super.mouseX <= 701) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[12] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 12;
				inventoryAltered = true;
			} else if ((super.mouseX >= 702) && (super.mouseX <= 731) && (super.mouseY >= 467)
			&& (super.mouseY <= 501) && (tabInterfaceIDs[13] != -1)) {
				drawInventoryRequest = true;
				inventoryHover = 13;
				inventoryAltered = true;
			} else {
				drawInventoryRequest = true;
				inventoryHover = -1;
				inventoryAltered = true;
			}
		} else {
			if (super.clickMode3 == 1) {
				if ((super.saveClickX >= 522) && (super.saveClickX <= 559)
				&& (super.saveClickY >= 169) && (super.saveClickY <= 202)
				&& (tabInterfaceIDs[0] != -1)) {
					drawInventoryRequest = true;
					tabID = 0;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 560) && (super.saveClickX <= 592)
				&& (super.saveClickY >= 168) && (super.saveClickY < 203)
				&& (tabInterfaceIDs[1] != -1)) {
					drawInventoryRequest = true;
					tabID = 1;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 593) && (super.saveClickX <= 625)
				&& (super.saveClickY >= 168) && (super.saveClickY < 203)
				&& (tabInterfaceIDs[2] != -1)) {
					drawInventoryRequest = true;
					tabID = 2;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 626) && (super.saveClickX <= 658)
				&& (super.saveClickY >= 168) && (super.saveClickY < 203)
				&& (tabInterfaceIDs[3] != -1)) {
					drawInventoryRequest = true;
					tabID = 3;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 659) && (super.saveClickX <= 691)
				&& (super.saveClickY >= 168) && (super.saveClickY < 203)
				&& (tabInterfaceIDs[4] != -1)) {
					drawInventoryRequest = true;
					tabID = 4;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 692) && (super.saveClickX <= 724)
				&& (super.saveClickY >= 168) && (super.saveClickY < 203)
				&& (tabInterfaceIDs[5] != -1)) {
					drawInventoryRequest = true;
					tabID = 5;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 725) && (super.saveClickX <= 762)
				&& (super.saveClickY >= 168) && (super.saveClickY < 203)
				&& (tabInterfaceIDs[6] != -1)) {
					drawInventoryRequest = true;
					tabID = 6;
					inventoryAltered = true;
				}
				if (((VERSION > 474) && (super.saveClickX >= 626) && (super.saveClickX <= 658)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503) && (tabInterfaceIDs[7] != -1))
				|| ((VERSION == 474) && (super.saveClickX >= 522) && (super.saveClickY <= 559)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503))) {
					drawInventoryRequest = true;
					tabID = 7;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 560) && (super.saveClickX <= 592)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503)
				&& (tabInterfaceIDs[8] != -1)) {
					drawInventoryRequest = true;
					tabID = 8;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 593) && (super.saveClickX <= 625)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503)
				&& (tabInterfaceIDs[9] != -1)) {
					drawInventoryRequest = true;
					tabID = 9;
					inventoryAltered = true;
				}
				if (((VERSION > 474) && (super.saveClickX >= 742) && (super.saveClickX <= 763)
				&& (super.saveClickY >= 1) && (super.saveClickY < 25) && (tabInterfaceIDs[10] != -1))
				|| ((VERSION == 474) && (super.saveClickX >= 626) && (super.saveClickX <= 658)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503))) {
					drawInventoryRequest = true;
					tabID = 10;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 659) && (super.saveClickX <= 691)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503)
				&& (tabInterfaceIDs[11] != -1)) {
					drawInventoryRequest = true;
					tabID = 11;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 692) && (super.saveClickX <= 724)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503)
				&& (tabInterfaceIDs[12] != -1)) {
					drawInventoryRequest = true;
					tabID = 12;
					inventoryAltered = true;
				}
				if ((super.saveClickX >= 725) && (super.saveClickX <= 762)
				&& (super.saveClickY >= 466) && (super.saveClickY <= 503)
				&& (tabInterfaceIDs[13] != -1)) {
					drawInventoryRequest = true;
					tabID = 13;
					inventoryAltered = true;
				}
			}
		}
	}

	private boolean promptUserForInput(Interface inputInterface) {
		int j = inputInterface.contentType;
		if (anInt900 == 2) {
			if (j == 201) {
				Client.inputTaken = true;
				inputDialogState = 0;
				messagePromptRaised = true;
				promptInput = "";
				friendsListAction = 1;
				messagePromptTitle = "Enter name of friend to add to list";
			}
			if (j == 202) {
				Client.inputTaken = true;
				inputDialogState = 0;
				messagePromptRaised = true;
				promptInput = "";
				friendsListAction = 2;
				messagePromptTitle = "Enter name of friend to delete from list";
			}
		}
		if (j == 205) {
			anInt1011 = 250;
			return true;
		}
		if (j == 501) {
			Client.inputTaken = true;
			inputDialogState = 0;
			messagePromptRaised = true;
			promptInput = "";
			friendsListAction = 4;
			messagePromptTitle = "Enter name of player to add to list";
		}
		if (j == 502) {
			Client.inputTaken = true;
			inputDialogState = 0;
			messagePromptRaised = true;
			promptInput = "";
			friendsListAction = 5;
			messagePromptTitle = "Enter name of player to delete from list";
		}
		if (j == 550) {
			Client.inputTaken = true;
			inputDialogState = 0;
			messagePromptRaised = true;
			promptInput = "";
			messagePromptTitle = "Enter the name of the chat you wish to join";
		}
		if ((j >= 300) && (j <= 313)) {
			int k = (j - 300) / 2;
			int j1 = j & 1;
			int i2 = anIntArray1065[k];
			if (i2 != -1) {
				do {
					if ((j1 == 0) && (--i2 < 0)) {
						i2 = IdentityKit.length - 1;
					}
					if ((j1 == 1) && (++i2 >= IdentityKit.length)) {
						i2 = 0;
					}
				} while (IdentityKit.cache[i2].aBoolean662
				|| (IdentityKit.cache[i2].anInt657 != k + (aBoolean1047 ? 0 : 7)));
				anIntArray1065[k] = i2;
				aBoolean1031 = true;
			}
		}
		if ((j >= 314) && (j <= 323)) {
			int l = (j - 314) / 2;
			int k1 = j & 1;
			int j2 = anIntArray990[l];
			if ((k1 == 0) && (--j2 < 0)) {
				j2 = Client.anIntArrayArray1003[l].length - 1;
			}
			if ((k1 == 1) && (++j2 >= Client.anIntArrayArray1003[l].length)) {
				j2 = 0;
			}
			anIntArray990[l] = j2;
			aBoolean1031 = true;
		}
		if ((j == 324) && !aBoolean1047) {
			aBoolean1047 = true;
			method45();
		}
		if ((j == 325) && aBoolean1047) {
			aBoolean1047 = false;
			method45();
		}
		if (j == 326) {
			outputStream.putOperation(101);
			outputStream.putByte(aBoolean1047 ? 0 : 1);
			for (int i1 = 0; i1 < 7; i1++) {
				outputStream.putByte(anIntArray1065[i1]);
			}
			for (int l1 = 0; l1 < 5; l1++) {
				outputStream.putByte(anIntArray990[l1]);
			}
			return true;
		}
		if (j == 613) {
			canMute = !canMute;
		}
		if ((j >= 601) && (j <= 612)) {
			clearTopInterfaces();
			if (reportAbuseInput.length() > 0) {
				outputStream.putOperation(218);
				outputStream.putLong(TextUtil.longForName(reportAbuseInput));
				outputStream.putByte(j - 601);
				outputStream.putByte(canMute ? 1 : 0);
			}
		}
		return false;
	}

	public void pushMessage(String message, int type, String s1) {
		if ((type == 0) && (dialogID != -1)) {
			continueMessageTitle = message;
			super.clickMode3 = 0;
		}
		if (backDialogID == -1) {
			Client.inputTaken = true;
		}
		for (int j = 499; j > 0; j--) {
			chatTypes[j] = chatTypes[j - 1];
			chatNames[j] = chatNames[j - 1];
			chatMessages[j] = chatMessages[j - 1];
			chatRights[j] = chatRights[j - 1];
		}
		chatTypes[0] = type;
		chatNames[0] = s1;
		chatMessages[0] = message;
		chatRights[0] = rights;
		if ((type == 0) || (type == 1) || (type == 2) || (type == 3) || (type == 4) || (type == 6)
		|| (type == 7) || (type == 16) || (type == 36)) {
			if ((chatTypeView != type) && (chatTypeView != 0)) {
				newTextDrawn[textDrawn(type)] = true;
			}
		}
	}

	@Override
	public void raiseWelcomeScreen() {
		welcomeScreenRaised = true;
	}

	private void randomizeImage(IndexedSprite indexedSprite) {
		int j = 256;
		for (int k = 0; k < anIntArray1190.length; k++) {
			anIntArray1190[k] = 0;
		}
		for (int l = 0; l < 5000; l++) {
			int i1 = (int) (Math.random() * 128D * j);
			anIntArray1190[i1] = (int) (Math.random() * 256D);
		}
		for (int j1 = 0; j1 < 20; j1++) {
			for (int k1 = 1; k1 < j - 1; k1++) {
				for (int i2 = 1; i2 < 127; i2++) {
					int k2 = i2 + (k1 << 7);
					anIntArray1191[k2] = (anIntArray1190[k2 - 1] + anIntArray1190[k2 + 1]
					+ anIntArray1190[k2 - 128] + anIntArray1190[k2 + 128]) / 4;
				}
			}
			int ai[] = anIntArray1190;
			anIntArray1190 = anIntArray1191;
			anIntArray1191 = ai;
		}
		if (indexedSprite != null) {
			int l1 = 0;
			for (int j2 = 0; j2 < indexedSprite.height; j2++) {
				for (int l2 = 0; l2 < indexedSprite.width; l2++) {
					if (indexedSprite.pixels[l1++] != 0) {
						int i3 = l2 + 16 + indexedSprite.offsetX;
						int j3 = j2 + 16 + indexedSprite.offsetY;
						int k3 = i3 + (j3 << 7);
						anIntArray1190[k3] = 0;
					}
				}
			}
		}
	}

	private boolean replayWave() {
		return Signlink.wavereplay();
	}

	public void resetAllGraphicsBuffers() {
		if (super.fullGameScreen != null) {
			return;
		}
		chatboxCanvas = null;
		minimapCanvas = null;
		inventoryCanvas = null;
		gameScreenCanvas = null;
		topLeftCanvas = null;
		bottomLeftCanvas = null;
		leftCanvas = null;
		leftFlameCanvas = null;
		rightFlameCanvas = null;
		titleBoxLeftCanvas = null;
		bottomRightCanvas = null;
		smallLeftCanvas = null;
		smallRightCanvas = null;
		super.fullGameScreen = new GraphicsBuffer(765, 503, getGameComponent());
		welcomeScreenRaised = true;
	}

	public void resetChatOptions() {
		chatTypeView = 0;
		for (int count = 0; count < flashRequest.length; count++) {
			flashRequest[count] = false;
		}
		for (int count = 0; count < newTextDrawn.length; count++) {
			newTextDrawn[count] = false;
		}
		for (int count = 0; count < 6; count++) {
			pauseFlash[count] = false;
			flashCount[count] = 4;
		}
	}

	private void resetTitleScreenGraphicsBuffers() {
		if (topLeftCanvas != null) {
			return;
		}
		super.fullGameScreen = null;
		chatboxCanvas = null;
		minimapCanvas = null;
		inventoryCanvas = null;
		gameScreenCanvas = null;
		leftFlameCanvas = new GraphicsBuffer(128, 265, getGameComponent());
		Renderer2D.clearPixels();
		rightFlameCanvas = new GraphicsBuffer(128, 265, getGameComponent());
		Renderer2D.clearPixels();
		topLeftCanvas = new GraphicsBuffer(509, 171, getGameComponent());
		Renderer2D.clearPixels();
		bottomLeftCanvas = new GraphicsBuffer(360, 132, getGameComponent());
		Renderer2D.clearPixels();
		leftCanvas = new GraphicsBuffer(360, 200, getGameComponent());
		Renderer2D.clearPixels();
		titleBoxLeftCanvas = new GraphicsBuffer(202, 238, getGameComponent());
		Renderer2D.clearPixels();
		bottomRightCanvas = new GraphicsBuffer(203, 238, getGameComponent());
		Renderer2D.clearPixels();
		smallLeftCanvas = new GraphicsBuffer(74, 94, getGameComponent());
		Renderer2D.clearPixels();
		smallRightCanvas = new GraphicsBuffer(75, 94, getGameComponent());
		Renderer2D.clearPixels();
		if (titleArchive != null) {
			drawTitleScreen();
			loadTitleScreen();
		}
		welcomeScreenRaised = true;
	}

	private void resetGameScreenGraphicsBuffers() {
		if (chatboxCanvas != null) {
			return;
		}
		nullLoader();
		super.fullGameScreen = null;
		topLeftCanvas = null;
		bottomLeftCanvas = null;
		leftCanvas = null;
		leftFlameCanvas = null;
		rightFlameCanvas = null;
		titleBoxLeftCanvas = null;
		bottomRightCanvas = null;
		smallLeftCanvas = null;
		smallRightCanvas = null;
		chatboxCanvas = new GraphicsBuffer(516, 165, getGameComponent());
		minimapCanvas = new GraphicsBuffer(249, 168, getGameComponent());
		Renderer2D.clearPixels();
		mapBackground[getImageId()].drawSprite(0, 0);
		inventoryCanvas = new GraphicsBuffer(249, 335, getGameComponent());
		gameScreenCanvas = new GraphicsBuffer(512, 334, getGameComponent());
		Renderer2D.clearPixels();
		welcomeScreenRaised = true;
	}

	private void resetLogout() {
		try {
			if (socketStream != null) {
				socketStream.close();
			}
		} catch (Exception _ex) {
		}
		socketStream = null;
		Client.loggedIn = false;
		loginScreenState = 0;
		unlinkMRUNodes();
		sceneGraph.initToNull();
		for (int i = 0; i < 4; i++) {
			collisionMap[i].reset();
		}
		System.gc();
		stopMidi();
		currentSong = -1;
		nextSong = -1;
		prevSong = 0;
		resetChatOptions();
		consoleOpen = false;
	}

	private void processFilterButtonClick() {
		if (((VERSION > 474) && (super.mouseX >= 4) && (super.mouseX < 60) && (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 3) && (super.mouseX < 60) && (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "View All";
			menuActionID[1] = 1450;
			menuActionRow++;
			chatFilterHover = 0;
			Client.inputTaken = true;
		} else if (((VERSION > 474) && (super.mouseX > 60) && (super.mouseX < 117)
		&& (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 69) && (super.mouseX < 126) && (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "View Game";
			menuActionID[1] = 1451;
			menuActionRow++;
			chatFilterHover = 1;
			Client.inputTaken = true;
		} else if (((VERSION > 474) && (super.mouseX > 117) && (super.mouseX < 174)
		&& (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 135) && (super.mouseX < 192)
		&& (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "Hide Public";
			menuActionID[1] = 1456;
			menuActionName[2] = "Off Public";
			menuActionID[2] = 1455;
			menuActionName[3] = "Friends Public";
			menuActionID[3] = 1454;
			menuActionName[4] = "On Public";
			menuActionID[4] = 1453;
			menuActionName[5] = "View Public";
			menuActionID[5] = 1452;
			menuActionRow = 6;
			chatFilterHover = 2;
			Client.inputTaken = true;
		} else if (((VERSION > 474) && (super.mouseX > 174) && (super.mouseX < 231)
		&& (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 200) && (super.mouseX < 258)
		&& (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "Off Private";
			menuActionID[1] = 1460;
			menuActionName[2] = "Friends Private";
			menuActionID[2] = 1459;
			menuActionName[3] = "On Private";
			menuActionID[3] = 1458;
			menuActionName[4] = "View Private";
			menuActionID[4] = 1457;
			menuActionRow = 5;
			chatFilterHover = 3;
			Client.inputTaken = true;
		} else if (((VERSION > 474) && (super.mouseX > 231) && (super.mouseX < 288)
		&& (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 267) && (super.mouseX < 324)
		&& (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "Off Clan";
			menuActionID[1] = 1464;
			menuActionName[2] = "Friends Clan";
			menuActionID[2] = 1463;
			menuActionName[3] = "On Clan";
			menuActionID[3] = 1462;
			menuActionName[4] = "View Clan";
			menuActionID[4] = 1461;
			menuActionRow = 5;
			chatFilterHover = 4;
			Client.inputTaken = true;
		} else if (((VERSION > 474) && (super.mouseX > 288) && (super.mouseX < 345)
		&& (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 333) && (super.mouseX < 390)
		&& (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "Off Trade";
			menuActionID[1] = 1468;
			menuActionName[2] = "Friends Trade";
			menuActionID[2] = 1467;
			menuActionName[3] = "On Trade";
			menuActionID[3] = 1466;
			menuActionName[4] = "View Trade";
			menuActionID[4] = 1465;
			menuActionRow = 5;
			chatFilterHover = 5;
			Client.inputTaken = true;
		} else if ((VERSION > 474) && (super.mouseX > 345) && (super.mouseX < 402)
		&& (super.mouseY >= 480) && (super.mouseY <= 503)) {
			menuActionName[1] = "Off Assist";
			menuActionID[1] = 1472;
			menuActionName[2] = "Friends Assist";
			menuActionID[2] = 1471;
			menuActionName[3] = "On Assist";
			menuActionID[3] = 1470;
			menuActionName[4] = "View Assist";
			menuActionID[4] = 1469;
			menuActionRow = 5;
			chatFilterHover = 6;
			Client.inputTaken = true;
		} else if (((VERSION > 474) && (super.mouseX > 402) && (super.mouseX <= 513)
		&& (super.mouseY >= 480) && (super.mouseY <= 503))
		|| ((VERSION == 474) && (super.mouseX > 402) && (super.mouseX < 514)
		&& (super.mouseY > 478) && (super.mouseY < 503))) {
			menuActionName[1] = "Report Abuse";
			menuActionID[1] = 606;
			menuActionRow++;
			chatFilterHover = 7;
			Client.inputTaken = true;
		} else {
			chatFilterHover = -1;
			Client.inputTaken = true;
		}
		if (super.clickMode3 == 1) {
			if (((VERSION > 474) && (super.saveClickX >= 5) && (super.saveClickX < 60)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 3) && (super.saveClickX < 60)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				chatTypeView = 0;
				Client.inputTaken = true;
			}
			if (((VERSION > 474) && (super.saveClickX > 60) && (super.saveClickX < 117)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 69) && (super.saveClickX < 126)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				chatTypeView = 1;
				Client.inputTaken = true;
			}
			if (((VERSION > 474) && (super.saveClickX > 117) && (super.saveClickX < 174)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 135) && (super.saveClickX < 192)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				chatTypeView = 2;
				Client.inputTaken = true;
			}
			if (((VERSION > 474) && (super.saveClickX > 174) && (super.saveClickX < 231)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 200) && (super.saveClickX < 258)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				chatTypeView = 3;
				Client.inputTaken = true;
			}
			if (((VERSION > 474) && (super.saveClickX > 231) && (super.saveClickX < 288)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 267) && (super.saveClickX < 324)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				chatTypeView = 4;
				Client.inputTaken = true;
			}
			if (((VERSION > 474) && (super.saveClickX > 288) && (super.saveClickX < 345)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 333) && (super.saveClickX < 390)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				chatTypeView = 5;
				Client.inputTaken = true;
			}
			if ((VERSION > 474) && (super.saveClickX > 345) && (super.saveClickX < 402)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503)) {
				chatTypeView = 6;
				Client.inputTaken = true;
			}
			if (((VERSION > 474) && (super.saveClickX > 402) && (super.saveClickX <= 511)
			&& (super.saveClickY >= 480) && (super.saveClickY <= 503))
			|| ((VERSION == 474) && (super.saveClickX > 402) && (super.saveClickX < 512)
			&& (super.saveClickY > 478) && (super.saveClickY < 503))) {
				if (openInterfaceID == -1) {
					clearTopInterfaces();
					reportAbuseInput = "";
					canMute = false;
					for (Interface element : Interface.interfaceCache) {
						if ((element == null) || (element.contentType != 600)) {
							continue;
						}
						reportAbuseInterfaceID = openInterfaceID = element.parentID;
						break;
					}
				} else {
					pushMessage(
					"Please close the interface you have open before using 'report abuse'", 0, "");
				}
			}
		}
	}

	private void processMinimapClick() {
		if ((super.mouseX >= 705) && (super.mouseX <= 762) && (super.mouseY >= 88)
		&& (super.mouseY <= 122)) {
			menuActionName[1] = isRunning ? "Turn run mode off" : "Turn run mode on";
			menuActionID[1] = 1449;
			menuActionRow = 2;
			statusGlobesHover = 1;
		} else {
			statusGlobesHover = 0;
		}
		if ((super.mouseX >= 744) && (super.mouseX <= 764) && (super.mouseY >= 0)
		&& (super.mouseY <= 20) && (tabInterfaceIDs[10] != -1)) {
			doorHover = 1;
		} else {
			doorHover = 0;
		}
		if ((super.mouseX >= 527) && (super.mouseX <= 559) && (super.mouseY >= 124)
		&& (super.mouseY <= 156)) {
			worldMapHover = 1;
		} else {
			worldMapHover = 0;
		}
	}

	@Override
	public void run() {
		if (drawFlames) {
			drawFlames();
		} else {
			super.run();
		}
	}

	private void saveMidi(boolean flag, byte abyte0[]) {
		Signlink.midifade = flag ? 1 : 0;
		Signlink.midisave(abyte0, abyte0.length);
	}

	private boolean saveWave(byte abyte0[], int i) {
		return (abyte0 == null) || Signlink.wavesave(abyte0, i);
	}

	public void sendFrame126(String str, int i) {
		Interface.interfaceCache[i].message = str;
		if (Interface.interfaceCache[i].parentID == tabInterfaceIDs[tabID]) {
			drawInventoryRequest = true;
		}
	}

	public void sendFrame219() {
		if (invOverlayInterfaceID != -1) {
			invOverlayInterfaceID = -1;
			drawInventoryRequest = true;
			inventoryAltered = true;
		}
		if (backDialogID != -1) {
			backDialogID = -1;
			Client.inputTaken = true;
		}
		if (inputDialogState != 0) {
			inputDialogState = 0;
			Client.inputTaken = true;
		}
		openInterfaceID = -1;
		aBoolean1149 = false;
	}

	public void sendFrame248(int interfaceID, int sideInterfaceID) {
		if (backDialogID != -1) {
			backDialogID = -1;
			Client.inputTaken = true;
		}
		if (inputDialogState != 0) {
			inputDialogState = 0;
			Client.inputTaken = true;
		}
		openInterfaceID = interfaceID;
		invOverlayInterfaceID = sideInterfaceID;
		drawInventoryRequest = true;
		inventoryAltered = true;
		aBoolean1149 = false;
	}

	public void sendFrame36(int id, int state) {
		anIntArray1045[id] = state;
		if (variousSettings[id] != state) {
			variousSettings[id] = state;
			processClientOptions(id);
			drawInventoryRequest = true;
			if (dialogID != -1) {
				Client.inputTaken = true;
			}
		}
	}

	public void sendPacket185(int buttonId, int toggleId, int type) {
		switch (type) {
			case 135:
				Interface button_1 = Interface.interfaceCache[buttonId];
				boolean flag8 = true;
				if (button_1.contentType > 0) {
					flag8 = promptUserForInput(button_1);
				}
				if (flag8) {
					outputStream.putOperation(185);
					outputStream.putShort(buttonId);
				}
				break;
			case 646:
				outputStream.putOperation(185);
				outputStream.putShort(buttonId);
				Interface button_2 = Interface.interfaceCache[buttonId];
				if ((button_2.valueIndexArray != null) && (button_2.valueIndexArray[0][0] == 5)) {
					if (variousSettings[toggleId] != button_2.anIntArray212[0]) {
						variousSettings[toggleId] = button_2.anIntArray212[0];
						processClientOptions(toggleId);
						drawInventoryRequest = true;
					}
				}
				break;
			case 169:
				outputStream.putOperation(185);
				outputStream.putShort(buttonId);
				Interface button_3 = Interface.interfaceCache[buttonId];
				if ((button_3.valueIndexArray != null) && (button_3.valueIndexArray[0][0] == 5)) {
					variousSettings[toggleId] = 1 - variousSettings[toggleId];
					processClientOptions(toggleId);
					drawInventoryRequest = true;
				}
				break;
		}
	}

	private void setCameraPos(int j, int k, int l, int i1, int j1, int k1) {
		int l1 = 2048 - k & 0x7ff;
		int i2 = 2048 - j1 & 0x7ff;
		int side2side = 0;
		int zoom = 0;
		int l2 = j;
		if (l1 != 0) {
			int i3 = Model.sineTable[l1];
			int k3 = Model.cosineTable[l1];
			int i4 = zoom * k3 - l2 * i3 >> 16;
			l2 = zoom * i3 + l2 * k3 >> 16;
			zoom = i4;
		}
		if (i2 != 0) {
			/*
			 * xxx if(cameratoggle){ if(zoom == 0) zoom = k2; if(lftrit == 0)
			 * lftrit = j2; if(fwdbwd == 0) fwdbwd = l2; k2 = zoom; j2 = lftrit;
			 * l2 = fwdbwd; }
			 */
			int j3 = Model.sineTable[i2];
			int l3 = Model.cosineTable[i2];
			int j4 = l2 * j3 + side2side * l3 >> 16;
			l2 = l2 * l3 - side2side * j3 >> 16;
			side2side = j4;
		}
		xCameraPos = l - side2side;
		zCameraPos = i1 - zoom;
		yCameraPos = k1 - l2;
		cameraPitch = k;
		cameraYaw = j1;
	}

	private void setWaveVolume(int i) {
		Signlink.wavevol = i;
	}

	private void showErrorScreen() {
		Graphics g = getGameComponent().getGraphics();
		g.setColor(Color.black);
		g.fillRect(0, 0, 765, 503);
		method4(1);
		if (loadingError) {
			flameRequest = false;
			g.setFont(new java.awt.Font("Helvetica", 1, 16));
			g.setColor(Color.yellow);
			int k = 35;
			g.drawString("Sorry, an error has occured whilst loading RuneScape", 30, k);
			k += 50;
			g.setColor(Color.white);
			g.drawString("To fix this try the following (in order):", 30, k);
			k += 50;
			g.setColor(Color.white);
			g.setFont(new java.awt.Font("Helvetica", 1, 12));
			g.drawString("1: Try closing ALL open web-browser windows, and reloading", 30, k);
			k += 30;
			g.drawString("2: Try clearing your web-browsers cache from tools->internet options",
			30, k);
			k += 30;
			g.drawString("3: Try using a different game-world", 30, k);
			k += 30;
			g.drawString("4: Try rebooting your computer", 30, k);
			k += 30;
			g.drawString("5: Try selecting a different version of Java from the play-game menu",
			30, k);
		}
		if (genericLoadingError) {
			flameRequest = false;
			g.setFont(new java.awt.Font("Helvetica", 1, 20));
			g.setColor(Color.white);
			g.drawString("Error - unable to load game!", 50, 50);
			g.drawString("To play RuneScape make sure you play from", 50, 100);
			g.drawString("http://www.runescape.com", 50, 150);
		}
		if (rsAlreadyLoaded) {
			flameRequest = false;
			g.setColor(Color.yellow);
			int l = 35;
			g.drawString("Error a copy of RuneScape already appears to be loaded", 30, l);
			l += 50;
			g.setColor(Color.white);
			g.drawString("To fix this try the following (in order):", 30, l);
			l += 50;
			g.setColor(Color.white);
			g.setFont(new java.awt.Font("Helvetica", 1, 12));
			g.drawString("1: Try closing ALL open web-browser windows, and reloading", 30, l);
			l += 30;
			g.drawString("2: Try rebooting your computer, and reloading", 30, l);
			l += 30;
		}
	}

	private void spawnGroundItem(int i, int j) {
		Deque deque = groundArray[plane][i][j];
		if (deque == null) {
			sceneGraph.method295(plane, i, j);
			return;
		}
		int k = 0xfa0a1f01;
		Object obj = null;
		for (Item item = (Item) deque.getFront(); item != null; item = (Item) deque
		.getNext()) {
			ItemDefinition itemDefinition = ItemDefinition.forID(item.ID);
			int l = itemDefinition.value;
			if (itemDefinition.stackable) {
				l *= item.anInt1559 + 1;
			}
			if (l > k) {
				k = l;
				obj = item;
			}
		}
		deque.insertFront(((Node) (obj)));
		Object obj1 = null;
		Object obj2 = null;
		for (Item item = (Item) deque.getFront(); item != null; item = (Item) deque
		.getNext()) {
			if ((item.ID != ((Item) (obj)).ID) && (obj1 == null)) {
				obj1 = item;
			}
			if ((item.ID != ((Item) (obj)).ID) && (item.ID != ((Item) (obj1)).ID) && (obj2 == null)) {
				obj2 = item;
			}
		}
		int i1 = i + (j << 7) + 0x60000000;
		sceneGraph.method281(i, i1, ((SceneModel) (obj1)), getEntityHeightOffset(plane, j * 128 + 64,
		i * 128 + 64), ((SceneModel) (obj2)), ((SceneModel) (obj)), plane, j);
	}

	@Override
	public void startRunnable(Runnable runnable, int i) {
		if (i > 10) {
			i = 10;
		}
		if (Signlink.mainapp != null) {
			Signlink.startthread(runnable, i);
		} else {
			super.startRunnable(runnable, i);
		}
	}

	@Override
	void startUp() {
		drawLoadingText(20, "Starting up");
		if (Signlink.sunjava) {
			super.minDelay = 5;
		}
		if (Client.aBoolean993) {
			// rsAlreadyLoaded = true;
			// return;
		}
		Client.aBoolean993 = true;
		if (Signlink.cache_dat != null) {
			for (int i = 0; i < 5; i++) {
				cacheIndices[i] = new FileStore(Signlink.cache_dat, Signlink.cache_idx[i], i + 1);
			}
		}
		try {
			titleArchive = getArchiveName(1, "title screen", "title", expectedCRCs[1], 25);
			smallText = new Font(false, "p11_full", titleArchive);
			plainText = new Font(false, "p12_full", titleArchive);
			boldText = new Font(false, "b12_full", titleArchive);
			Font fancyText = new Font(true, "q8_full", titleArchive);
			drawTitleScreen();
			loadTitleScreen();
			Archive archive = getArchiveName(2, "config", "config", expectedCRCs[2], 30);
			Archive configArvhive = getArchiveName(3, "interface", "interface", expectedCRCs[3], 35);
			Archive mediaArchive = getArchiveName(4, "2d graphics", "media", expectedCRCs[4], 40);
			Archive textureArchive = getArchiveName(6, "textures", "textures", expectedCRCs[6], 45);
			Archive chatArchive = getArchiveName(7, "chat system", "wordenc", expectedCRCs[7], 50);
			Archive soundArchive = getArchiveName(8, "sound effects", "sounds", expectedCRCs[8], 55);
			byteGroundArray = new byte[4][104][104];
			averageTileHeight = new int[4][105][105];
			sceneGraph = new SceneGraph(averageTileHeight);
			for (int j = 0; j < 4; j++) {
				collisionMap[j] = new CollisionMap();
			}
			miniMap = new Sprite(512, 512);
			Archive versionArchive = getArchiveName(5, "update list", "versionlist",
			expectedCRCs[5], 60);
			drawLoadingText(60, "Connecting to update server");
			onDemandFetcher = new OnDemandFetcher();
			onDemandFetcher.start(versionArchive, this);
			FrameReader.method528(onDemandFetcher.getAnimCount());
			Model.method459(onDemandFetcher.getVersionCount(0), onDemandFetcher);
			// ModelDecompressor.loadModels();
			// preloadModels();
			if (!Client.lowMem) {
				nextSong = 0;
				try {
					nextSong = Integer.parseInt(getParameter("music"));
				} catch (Exception _ex) {
				}
				songChanging = true;
				onDemandFetcher.method558(2, nextSong);
				while (onDemandFetcher.getNodeCount() > 0) {
					processOnDemandQueue();
					try {
						Thread.sleep(100L);
					} catch (Exception _ex) {
					}
					if (onDemandFetcher.anInt1349 > 3) {
						loadError();
						return;
					}
				}
			}
			drawLoadingText(65, "Requesting animations");
			int k = onDemandFetcher.getVersionCount(1);
			for (int i1 = 0; i1 < k; i1++) {
				onDemandFetcher.method558(1, i1);
			}
			while (onDemandFetcher.getNodeCount() > 0) {
				int j1 = k - onDemandFetcher.getNodeCount();
				if (j1 > 0) {
					drawLoadingText(65, "Loading animations - " + (j1 * 100) / k + "%");
				}
				processOnDemandQueue();
				try {
					Thread.sleep(100L);
				} catch (Exception _ex) {
				}
				if (onDemandFetcher.anInt1349 > 3) {
					loadError();
					return;
				}
			}
			drawLoadingText(70, "Requesting models");
			k = onDemandFetcher.getVersionCount(0);
			for (int k1 = 0; k1 < k; k1++) {
				int l1 = onDemandFetcher.getModelIndex(k1);
				if ((l1 & 1) != 0) {
					onDemandFetcher.method558(0, k1);
				}
			}
			k = onDemandFetcher.getNodeCount();
			while (onDemandFetcher.getNodeCount() > 0) {
				int i2 = k - onDemandFetcher.getNodeCount();
				if (i2 > 0) {
					drawLoadingText(70, "Loading models - " + (i2 * 100) / k + "%");
				}
				processOnDemandQueue();
				try {
					Thread.sleep(100L);
				} catch (Exception _ex) {
				}
			}
			if (cacheIndices[0] != null) {
				drawLoadingText(75, "Requesting maps");
				onDemandFetcher.method558(3, onDemandFetcher.method562(0, 48, 47));
				onDemandFetcher.method558(3, onDemandFetcher.method562(1, 48, 47));
				onDemandFetcher.method558(3, onDemandFetcher.method562(0, 48, 48));
				onDemandFetcher.method558(3, onDemandFetcher.method562(1, 48, 48));
				onDemandFetcher.method558(3, onDemandFetcher.method562(0, 48, 49));
				onDemandFetcher.method558(3, onDemandFetcher.method562(1, 48, 49));
				onDemandFetcher.method558(3, onDemandFetcher.method562(0, 47, 47));
				onDemandFetcher.method558(3, onDemandFetcher.method562(1, 47, 47));
				onDemandFetcher.method558(3, onDemandFetcher.method562(0, 47, 48));
				onDemandFetcher.method558(3, onDemandFetcher.method562(1, 47, 48));
				onDemandFetcher.method558(3, onDemandFetcher.method562(0, 148, 48));
				onDemandFetcher.method558(3, onDemandFetcher.method562(1, 148, 48));
				k = onDemandFetcher.getNodeCount();
				while (onDemandFetcher.getNodeCount() > 0) {
					int j2 = k - onDemandFetcher.getNodeCount();
					if (j2 > 0) {
						drawLoadingText(75, "Loading maps - " + (j2 * 100) / k + "%");
					}
					processOnDemandQueue();
					try {
						Thread.sleep(100L);
					} catch (Exception _ex) {
					}
				}
			}
			k = onDemandFetcher.getVersionCount(0);
			for (int k2 = 0; k2 < k; k2++) {
				int l2 = onDemandFetcher.getModelIndex(k2);
				byte byte0 = 0;
				if ((l2 & 8) != 0) {
					byte0 = 10;
				} else if ((l2 & 0x20) != 0) {
					byte0 = 9;
				} else if ((l2 & 0x10) != 0) {
					byte0 = 8;
				} else if ((l2 & 0x40) != 0) {
					byte0 = 7;
				} else if ((l2 & 0x80) != 0) {
					byte0 = 6;
				} else if ((l2 & 2) != 0) {
					byte0 = 5;
				} else if ((l2 & 4) != 0) {
					byte0 = 4;
				}
				if ((l2 & 1) != 0) {
					byte0 = 3;
				}
				if (byte0 != 0) {
					onDemandFetcher.method563(byte0, 0, k2);
				}
			}
			onDemandFetcher.method554(Client.isMembers);
			if (!Client.lowMem) {
				int l = onDemandFetcher.getVersionCount(2);
				for (int i3 = 1; i3 < l; i3++) {
					if (onDemandFetcher.method569(i3)) {
						onDemandFetcher.method563((byte) 1, 2, i3);
					}
				}
			}
			drawLoadingText(80, "Unpacking media");
			roundMapBack = new IndexedSprite(mediaArchive, "mapback", 0);
			for (int count = 0; count < sideIcons.length; count++) {
				sideIcons[count] = new Sprite("sideicons", count);
			}
			for (int count = 0; count < redStones.length; count++) {
				redStones[count] = new Sprite("redstones", count);
			}
			for (int count = 0; count < filterButtons.length; count++) {
				filterButtons[count] = new Sprite("filterbuttons", count);
			}
			for (int count = 0; count < scrollBar.length; count++) {
				scrollBar[count] = new Sprite("scrollbar", count);
			}
			for (int count = 0; count < statusGlobes.length; count++) {
				statusGlobes[count] = new Sprite("globes", count);
			}
			for (int count = 0; count < chatBox.length; count++) {
				chatBox[count] = new Sprite("chatbox", count);
			}
			for (int count = 0; count < inventory.length; count++) {
				inventory[count] = new Sprite("inventory", count);
			}
			for (int count = 0; count < mapBackground.length; count++) {
				mapBackground[count] = new Sprite("map", count);
			}
			for (int count = 0; count < logoutDoor.length; count++) {
				logoutDoor[count] = new Sprite("logoutdoor", count);
			}
			for (int count = 0; count < worldMapGlobe.length; count++) {
				worldMapGlobe[count] = new Sprite("mapglobe", count);
			}
			for (int count = 0; count < hoverStones.length; count++) {
				hoverStones[count] = new Sprite("hoverstones", count);
			}
			for (int count = 0; count < newHitMarks.length; count++) {
				newHitMarks[count] = new Sprite("hitmarks", count);
			}
			compass = new Sprite("compass", 0);
			mapEdge = new Sprite(mediaArchive, "mapedge", 0);
			mapEdge.trim();
			try {
				for (int k3 = 0; k3 < 100; k3++) {
					mapScenes[k3] = new IndexedSprite(mediaArchive, "mapscene", k3);
				}
			} catch (Exception _ex) {
			}
			try {
				for (int l3 = 0; l3 < 100; l3++) {
					mapFunctions[l3] = new Sprite(mediaArchive, "mapfunction", l3);
				}
			} catch (Exception _ex) {
			}
			try {
				for (int count = 0; count < hitMarks.length; count++) {
					hitMarks[count] = new Sprite(mediaArchive, "hitmarks", count);
				}
			} catch (Exception _ex) {
			}
			try {
				for (int h1 = 0; h1 < 6; h1++) {
					headIcons_hint[h1] = new Sprite(mediaArchive, "headicons_hint", h1);
				}
			} catch (Exception _ex) {
			}
			try {
				for (int j4 = 0; j4 < 8; j4++) {
					headIcons_prayer[j4] = new Sprite(mediaArchive, "headicons_prayer", j4);
				}
			} catch (Exception _ex) {
			}
			try {
				for (int j45 = 0; j45 < 3; j45++) {
					headIcons_pk[j45] = new Sprite(mediaArchive, "headicons_pk", j45);
				}
			} catch (Exception _ex) {
			}
			mapFlag = new Sprite(mediaArchive, "mapmarker", 0);
			mapMarker = new Sprite(mediaArchive, "mapmarker", 1);
			for (int k4 = 0; k4 < 8; k4++) {
				crosses[k4] = new Sprite(mediaArchive, "cross", k4);
			}
			mapDotItem = new Sprite(mediaArchive, "mapdots", 0);
			mapDotNPC = new Sprite(mediaArchive, "mapdots", 1);
			mapDotPlayer = new Sprite(mediaArchive, "mapdots", 2);
			mapDotFriend = new Sprite(mediaArchive, "mapdots", 3);
			mapDotTeam = new Sprite(mediaArchive, "mapdots", 4);
			for (int l4 = 0; l4 < 2; l4++) {
				modIcons[l4] = new IndexedSprite(mediaArchive, "mod_icons", l4);
			}
			Sprite sprite = new Sprite("frame", 0);
			leftFrame = new GraphicsBuffer(sprite.width, sprite.height, getGameComponent());
			sprite.drawInverse(0, 0);
			sprite = new Sprite("frame", 1);
			topFrame = new GraphicsBuffer(sprite.width, sprite.height, getGameComponent());
			sprite.drawInverse(0, 0);
			int red = (int) (Math.random() * 21D) - 10;
			int green = (int) (Math.random() * 21D) - 10;
			int blue = (int) (Math.random() * 21D) - 10;
			int offset = (int) (Math.random() * 41D) - 20;
			for (int id = 0; id < 100; id++) {
				if (mapFunctions[id] != null) {
					mapFunctions[id].adjustColors(red + offset, green + offset, blue + offset);
				}
				if (mapScenes[id] != null) {
					mapScenes[id].adjustColors(red + offset, green + offset, blue + offset);
				}
			}
			drawLoadingText(83, "Unpacking textures");
			Renderer3D.unpackTextures(textureArchive);
			Renderer3D.setPallete(0.80000000000000004D);
			Renderer3D.resetTextures();
			drawLoadingText(86, "Unpacking configuration");
			Animation.unpackConfig(archive);
			ObjectDefinition.unpackConfig(archive);
			Floor.unpackConfig(archive);
			ItemDefinition.unpackConfig(archive);
			EntityDefinition.unpackConfig(archive);
			IdentityKit.unpackConfig(archive);
			SpotAnimation.unpackConfig(archive);
			Varp.unpackConfig(archive);
			VarBit.unpackConfig(archive);
			ItemDefinition.isMembers = Client.isMembers;
			if (!Client.lowMem) {
				drawLoadingText(90, "Unpacking sounds");
				byte sounds[] = soundArchive.getFile("sounds.dat");
				Packet buffer = new Packet(sounds);
				Sounds.unpack(buffer);
			}
			drawLoadingText(95, "Unpacking interfaces");
			Font fonts[] = { smallText, plainText, boldText, fancyText };
			Interface.unpack(configArvhive, fonts, mediaArchive);
			drawLoadingText(100, "Preparing game engine");
			for (int y = 0; y < 33; y++) {
				int mapNigga = 999;
				int src = 0;
				for (int x = 0; x < 34; x++) {
					if (roundMapBack.pixels[x + y * roundMapBack.width] == 0) {
						if (mapNigga == 999) {
							mapNigga = x;
						}
						continue;
					}
					if (mapNigga == 999) {
						continue;
					}
					src = x;
					break;
				}
				compassTrimLeft[y] = mapNigga;
				compassTrimRight[y] = src - mapNigga;
			}
			for (int y = 0; y < 153; y++) {
				int mapNigga = 999;
				int src = 0;
				for (int x = 24; x < 177; x++) {
					if ((roundMapBack.pixels[x + y * roundMapBack.width] == 0)
					&& ((x > 34) || (y > 34))) {
						if (mapNigga == 999) {
							mapNigga = x;
						}
						continue;
					}
					if (mapNigga == 999) {
						continue;
					}
					src = x;
					break;
				}
				miniMapTrimLeft[y] = mapNigga - 24;
				miniMapTrimRight[y] = src - mapNigga;
			}
			Renderer3D.init(765, 503);
			fullScreenTexturePool = Renderer3D.lineOffsets;
			Renderer3D.init(516, 168);
			chatboxTexturePool = Renderer3D.lineOffsets;
			Renderer3D.init(249, 335);
			inventoryTexturePool = Renderer3D.lineOffsets;
			Renderer3D.init(512, 334);
			gameScreenTexturePool = Renderer3D.lineOffsets;
			int pixels[] = new int[9];
			for (int i8 = 0; i8 < 9; i8++) {
				int k8 = 128 + i8 * 32 + 15;
				int l8 = 600 + k8 * 3;
				int i9 = Renderer3D.sineTable[k8];
				pixels[i8] = l8 * i9 >> 16;
			}
			SceneGraph.init(500, 800, 512, 334, pixels);
			Censor.loadConfig(chatArchive);
			mouseDetection = new MouseDetection(this);
			startRunnable(mouseDetection, 10);
			AnimatedObject.clientInstance = this;
			ObjectDefinition.clientInstance = this;
			EntityDefinition.clientInstance = this;
			return;
		} catch (Exception exception) {
			Signlink.reporterror("loaderror " + loadingText + " " + loadingTextWidth);
		}
		loadingError = true;
	}

	private void stopMidi() {
		Signlink.midifade = 0;
		Signlink.midi = "stop";
	}

	public int textDrawn(int inputId) {
		if (inputId == 0) {
			return 0;
		}
		if ((inputId == 1) || (inputId == 2)) {
			return 1;
		}
		if ((inputId == 3) || (inputId == 6) || (inputId == 7)) {
			return 2;
		}
		if (inputId == 16) {
			return 3;
		}
		if (inputId == 4) {
			return 4;
		}
		if (inputId == 36) {
			return 5;
		}
		return inputId;
	}

	private void unlinkMRUNodes() {
		ObjectDefinition.mruNodes1.clear();
		ObjectDefinition.mruNodes2.clear();
		EntityDefinition.npcCache.clear();
		ItemDefinition.modelCache.clear();
		ItemDefinition.spriteCache.clear();
		Player.modelCache.clear();
		SpotAnimation.gfxCache.clear();
	}

	private void updateEntities() {
		try {
			int anInt974 = 0;
			for (int j = -1; j < playerCount + npcCount; j++) {
				Object obj;
				if (j == -1) {
					obj = Client.myPlayer;
				} else if (j < playerCount) {
					obj = playerArray[playerIndices[j]];
				} else {
					obj = npcArray[npcIndices[j - playerCount]];
				}
				if ((obj == null) || !((Entity) (obj)).isVisible()) {
					continue;
				}
				if (obj instanceof Npc) {
					EntityDefinition entityDefinition = ((Npc) obj).desc;
					if (entityDefinition.childrenIDs != null) {
						entityDefinition = entityDefinition.method161();
					}
					if (entityDefinition == null) {
						continue;
					}
				}
				if (j < playerCount) {
					int l = 30;
					Player player = (Player) obj;
					if (player.prayerIcon >= 0) {
						worldToScreen(((Entity) (obj)), ((Entity) (obj)).height + 15);
						if (spriteDrawX > -1) {
							if (player.skullIcon < 2) {
								headIcons_pk[player.skullIcon].drawSprite(spriteDrawX - 12,
								spriteDrawY - l);
								l += 25;
							}
							if (player.prayerIcon < 7) {
								headIcons_prayer[player.prayerIcon].drawSprite(spriteDrawX - 12,
								spriteDrawY - l);
								l += 18;
							}
						}
					}
					if ((j >= 0) && (anInt855 == 10) && (anInt933 == playerIndices[j])) {
						worldToScreen(((Entity) (obj)), ((Entity) (obj)).height + 15);
						if (spriteDrawX > -1) {
							headIcons_hint[player.hintIcon].drawSprite(spriteDrawX - 12,
							spriteDrawY - l);
						}
					}
				} else {
					EntityDefinition entityDef_1 = ((Npc) obj).desc;
					if ((entityDef_1.anInt75 >= 0)
					&& (entityDef_1.anInt75 < headIcons_prayer.length)) {
						worldToScreen(((Entity) (obj)), ((Entity) (obj)).height + 15);
						if (spriteDrawX > -1) {
							headIcons_prayer[entityDef_1.anInt75].drawSprite(spriteDrawX - 12,
							spriteDrawY - 30);
						}
					}
					if ((anInt855 == 1) && (anInt1222 == npcIndices[j - playerCount])
					&& (Client.loopCycle % 20 < 10)) {
						worldToScreen(((Entity) (obj)), ((Entity) (obj)).height + 15);
						if (spriteDrawX > -1) {
							headIcons_hint[0].drawSprite(spriteDrawX - 12, spriteDrawY - 28);
						}
					}
				}
				if ((((Entity) (obj)).textSpoken != null)
				&& ((j >= playerCount) || (publicChatMode == 0) || (publicChatMode == 3) || ((publicChatMode == 1) && isFriendOrSelf(((Player) obj).name)))) {
					worldToScreen(((Entity) (obj)), ((Entity) (obj)).height);
					if ((spriteDrawX > -1) && (anInt974 < anInt975)) {
						anIntArray979[anInt974] = boldText
						.getAlphaNumericTextWidth(((Entity) (obj)).textSpoken) / 2;
						anIntArray978[anInt974] = boldText.offset;
						anIntArray976[anInt974] = spriteDrawX;
						anIntArray977[anInt974] = spriteDrawY;
						anIntArray980[anInt974] = ((Entity) (obj)).anInt1513;
						anIntArray981[anInt974] = ((Entity) (obj)).textEffects;
						anIntArray982[anInt974] = ((Entity) (obj)).textCycle;
						entityOverheadChat[anInt974++] = ((Entity) (obj)).textSpoken;
						if ((anInt1249 == 0) && (((Entity) (obj)).textEffects >= 1)
						&& (((Entity) (obj)).textEffects <= 3)) {
							anIntArray978[anInt974] += 10;
							anIntArray977[anInt974] += 5;
						}
						if ((anInt1249 == 0) && (((Entity) (obj)).textEffects == 4)) {
							anIntArray979[anInt974] = 60;
						}
						if ((anInt1249 == 0) && (((Entity) (obj)).textEffects == 5)) {
							anIntArray978[anInt974] += 5;
						}
					}
				}
				if (((Entity) (obj)).combatCycle > Client.loopCycle) {
					try {
						worldToScreen(((Entity) (obj)), ((Entity) (obj)).height + 15);
						if (spriteDrawX > -1) {
							int width = (((Entity) (obj)).currentHealth * 30)
							/ ((Entity) (obj)).maxHealth;
							if (width > 30) {
								width = 30;
							}
							Renderer2D.fillRectangle(spriteDrawX - 15, spriteDrawY - 3, width, 5,
							65280);
							Renderer2D.fillRectangle((spriteDrawX - 15) + width, spriteDrawY - 3,
							30 - width, 5, 0xff0000);
						}
					} catch (Exception e) {
					}
				}
				for (int j1 = 0; j1 < 4; j1++) {
					if (((Entity) (obj)).damageCycles[j1] > Client.loopCycle) {
						worldToScreen(((Entity) (obj)), ((Entity) (obj)).height / 2);
						if (spriteDrawX > -1) {
							if (j1 == 1) {
								spriteDrawY -= 20;
							}
							if (j1 == 2) {
								spriteDrawX -= 15;
								spriteDrawY -= 10;
							}
							if (j1 == 3) {
								spriteDrawX += 15;
								spriteDrawY -= 10;
							}
							if (VERSION > 508) {
								newHitMarks[((Entity) (obj)).damageTypes[j1]].drawAlphaSprite(
								spriteDrawX - 12, spriteDrawY - 12);
							} else {
								hitMarks[((Entity) (obj)).damageTypes[j1]].drawSprite(
								spriteDrawX - 12, spriteDrawY - 12);
							}
							smallText.drawCenteredText(String
							.valueOf(((Entity) (obj)).damageValues[j1]), spriteDrawX,
							spriteDrawY + 4, 0);
							smallText.drawCenteredText(String
							.valueOf(((Entity) (obj)).damageValues[j1]), spriteDrawX - 1,
							spriteDrawY + 3, 0xffffff);
						}
					}
				}
			}
			for (int k = 0; k < anInt974; k++) {
				int k1 = anIntArray976[k];
				int l1 = anIntArray977[k];
				int j2 = anIntArray979[k];
				int k2 = anIntArray978[k];
				boolean flag = true;
				while (flag) {
					flag = false;
					for (int l2 = 0; l2 < k; l2++) {
						if ((l1 + 2 > anIntArray977[l2] - anIntArray978[l2])
						&& (l1 - k2 < anIntArray977[l2] + 2)
						&& (k1 - j2 < anIntArray976[l2] + anIntArray979[l2])
						&& (k1 + j2 > anIntArray976[l2] - anIntArray979[l2])
						&& (anIntArray977[l2] - anIntArray978[l2] < l1)) {
							l1 = anIntArray977[l2] - anIntArray978[l2];
							flag = true;
						}
					}
				}
				spriteDrawX = anIntArray976[k];
				spriteDrawY = anIntArray977[k] = l1;
				String message = entityOverheadChat[k];
				if (anInt1249 == 0) {
					int color = 0xffff00;
					if (anIntArray980[k] < 6) {
						color = colors[anIntArray980[k]];
					}
					if (anIntArray980[k] == 6) {
						color = anInt1265 % 20 >= 10 ? 0xffff00 : 0xff0000;
					}
					if (anIntArray980[k] == 7) {
						color = anInt1265 % 20 >= 10 ? 65535 : 255;
					}
					if (anIntArray980[k] == 8) {
						color = anInt1265 % 20 >= 10 ? 0x80ff80 : 45056;
					}
					if (anIntArray980[k] == 9) {
						int j3 = 150 - anIntArray982[k];
						if (j3 < 50) {
							color = 0xff0000 + 1280 * j3;
						} else if (j3 < 100) {
							color = 0xffff00 - 0x50000 * (j3 - 50);
						} else if (j3 < 150) {
							color = 65280 + 5 * (j3 - 100);
						}
					}
					if (anIntArray980[k] == 10) {
						int k3 = 150 - anIntArray982[k];
						if (k3 < 50) {
							color = 0xff0000 + 5 * k3;
						} else if (k3 < 100) {
							color = 0xff00ff - 0x50000 * (k3 - 50);
						} else if (k3 < 150) {
							color = (255 + 0x50000 * (k3 - 100)) - 5 * (k3 - 100);
						}
					}
					if (anIntArray980[k] == 11) {
						int l3 = 150 - anIntArray982[k];
						if (l3 < 50) {
							color = 0xffffff - 0x50005 * l3;
						} else if (l3 < 100) {
							color = 65280 + 0x50005 * (l3 - 50);
						} else if (l3 < 150) {
							color = 0xffffff - 0x50000 * (l3 - 100);
						}
					}
					if (anIntArray981[k] == 0) {
						boldText.drawCenteredText(message, spriteDrawX, spriteDrawY + 1, 0);
						boldText.drawCenteredText(message, spriteDrawX, spriteDrawY, color);
					}
					if (anIntArray981[k] == 1) {
						boldText.drawWaveText(message, spriteDrawX, spriteDrawY + 1, 0, anInt1265);
						boldText.drawWaveText(message, spriteDrawX, spriteDrawY, color, anInt1265);
					}
					if (anIntArray981[k] == 2) {
						boldText.drawWave2Text(message, spriteDrawX, anInt1265, 0, spriteDrawY + 1);
						boldText.drawWave2Text(message, spriteDrawX, anInt1265, color, spriteDrawY);
					}
					if (anIntArray981[k] == 3) {
						boldText.drawShakeText(message, spriteDrawX, spriteDrawY + 1,
						150 - anIntArray982[k], anInt1265, 0);
						boldText.drawShakeText(message, spriteDrawX, spriteDrawY,
						150 - anIntArray982[k], anInt1265, color);
					}
					if (anIntArray981[k] == 4) {
						int i4 = boldText.getAlphaNumericTextWidth(message);
						int k4 = ((150 - anIntArray982[k]) * (i4 + 100)) / 150;
						Renderer2D.setDrawingArea(spriteDrawX - 50, 0, spriteDrawX + 50, 334);
						boldText.drawText(message, (spriteDrawX + 50) - k4, spriteDrawY + 1, 0);
						boldText.drawText(message, (spriteDrawX + 50) - k4, spriteDrawY, color);
						Renderer2D.setDefaultDrawingAreaSize();
					}
					if (anIntArray981[k] == 5) {
						int j4 = 150 - anIntArray982[k];
						int l4 = 0;
						if (j4 < 25) {
							l4 = j4 - 25;
						} else if (j4 > 125) {
							l4 = j4 - 125;
						}
						Renderer2D.setDrawingArea(0, spriteDrawY - boldText.offset - 1, 512,
						spriteDrawY + 5);
						boldText.drawCenteredText(message, spriteDrawX, spriteDrawY + 1 + l4, 0);
						boldText.drawCenteredText(message, spriteDrawX, spriteDrawY + l4, color);
						Renderer2D.setDefaultDrawingAreaSize();
					}
				} else {
					boldText.drawCenteredText(message, spriteDrawX, spriteDrawY + 1, 0);
					boldText.drawCenteredText(message, spriteDrawX, spriteDrawY, 0xffff00);
				}
			}
		} catch (Exception e) {
		}
	}

	private void updateNPCs(Packet buffer, int i) {
		anInt839 = 0;
		anInt893 = 0;
		method139(buffer);
		method46(i, buffer);
		method86(buffer);
		for (int k = 0; k < anInt839; k++) {
			int l = anIntArray840[k];
			if (npcArray[l].anInt1537 != Client.loopCycle) {
				npcArray[l].desc = null;
				npcArray[l] = null;
			}
		}
		if (buffer.offset != i) {
			Signlink.reporterror(myUsername + " size mismatch in getnpcpos - pos:" + buffer.offset
			+ " psize:" + i);
			throw new RuntimeException("eek");
		}
		for (int i1 = 0; i1 < npcCount; i1++) {
			if (npcArray[npcIndices[i1]] == null) {
				Signlink.reporterror(myUsername + " null entry in npc list - pos:" + i1 + " size:"
				+ npcCount);
				throw new RuntimeException("eek");
			}
		}
	}

	private void updatePlayers(int i, Packet buffer) {
		anInt839 = 0;
		anInt893 = 0;
		method117(buffer);
		method134(buffer);
		method91(buffer, i);
		method49(buffer);
		for (int k = 0; k < anInt839; k++) {
			int l = anIntArray840[k];
			if (playerArray[l].anInt1537 != Client.loopCycle) {
				playerArray[l] = null;
			}
		}
		if (buffer.offset != i) {
			Signlink.reporterror("Error packet size mismatch in getplayer pos:" + buffer.offset
			+ " psize:" + i);
			throw new RuntimeException("eek");
		}
		for (int i1 = 0; i1 < playerCount; i1++) {
			if (playerArray[playerIndices[i1]] == null) {
				Signlink.reporterror(myUsername + " null entry in pl list - pos:" + i1 + " size:"
				+ playerCount);
				throw new RuntimeException("eek");
			}
		}
	}

	public void updateStrings(String type, int id) {
		switch (id) {
			case 1675:
				sendFrame126(type, 17508);
				break;// Stab
			case 1676:
				sendFrame126(type, 17509);
				break;// Slash
			case 1677:
				sendFrame126(type, 17510);
				break;// Crush
			case 1678:
				sendFrame126(type, 17511);
				break;// Magic
			case 1679:
				sendFrame126(type, 17512);
				break;// Range
			case 1680:
				sendFrame126(type, 17513);
				break;// Stab
			case 1681:
				sendFrame126(type, 17514);
				break;// Slash
			case 1682:
				sendFrame126(type, 17515);
				break;// Crush
			case 1683:
				sendFrame126(type, 17516);
				break;// Magic
			case 1684:
				sendFrame126(type, 17517);
				break;// Range
			case 1686:
				sendFrame126(type, 17518);
				break;// Strength
			case 1687:
				sendFrame126(type, 17519);
				break;// Prayer
		}
	}

	public Client() {
		consoleInput = "";
		Client.consoleOpen = false;
		consoleMessages = new String[17];
		fullscreenInterfaceID = -1;
		chatRights = new int[500];
		chatTypeView = 0;
		clanChatMode = 0;
		Client.server = "127.0.0.1";
		anIntArrayArray825 = new int[104][104];
		friendsNodeIDs = new int[200];
		groundArray = new Deque[4][104][104];
		flameRequest = false;
		chatBuffers = new Packet(new byte[5000]);
		npcArray = new Npc[16384];
		npcIndices = new int[16384];
		anIntArray840 = new int[1000];
		settingsBuffers = Packet.create();
		aBoolean848 = true;
		openInterfaceID = -1;
		currentExp = new int[Skills.skillsCount];
		aBoolean872 = false;
		anIntArray873 = new int[5];
		anInt874 = -1;
		aBooleanArray876 = new boolean[5];
		drawFlames = false;
		reportAbuseInput = "";
		unknownInt10 = -1;
		menuOpen = false;
		inputString = "";
		maxPlayers = 2048;
		myPlayerIndex = 2047;
		playerArray = new Player[maxPlayers];
		playerIndices = new int[maxPlayers];
		anIntArray894 = new int[maxPlayers];
		playerAppearanceBuffers = new Packet[maxPlayers];
		anInt897 = 1;
		anIntArrayArray901 = new int[104][104];
		destTexture = new byte[16384];
		currentStats = new int[Skills.skillsCount];
		ignoreListAsLongs = new long[100];
		loadingError = false;
		anIntArray928 = new int[5];
		anIntArrayArray929 = new int[104][104];
		chatTypes = new int[500];
		chatNames = new String[500];
		chatMessages = new String[500];
		aBoolean954 = true;
		friendsListAsLongs = new long[200];
		currentSong = -1;
		drawingFlames = false;
		spriteDrawX = -1;
		spriteDrawY = -1;
		compassTrimLeft = new int[33];
		anIntArray969 = new int[256];
		cacheIndices = new FileStore[5];
		variousSettings = new int[2000];
		aBoolean972 = false;
		anInt975 = 50;
		anIntArray976 = new int[anInt975];
		anIntArray977 = new int[anInt975];
		anIntArray978 = new int[anInt975];
		anIntArray979 = new int[anInt975];
		anIntArray980 = new int[anInt975];
		anIntArray981 = new int[anInt975];
		anIntArray982 = new int[anInt975];
		entityOverheadChat = new String[anInt975];
		anInt985 = -1;
		hitMarks = new Sprite[20];
		anIntArray990 = new int[5];
		aBoolean994 = false;
		amountOrNameInput = "";
		projectileList = new Deque();
		aBoolean1017 = false;
		anInt1018 = -1;
		anIntArray1030 = new int[5];
		aBoolean1031 = false;
		mapFunctions = new Sprite[100];
		dialogID = -1;
		maxStats = new int[Skills.skillsCount];
		anIntArray1045 = new int[2000];
		aBoolean1047 = true;
		miniMapTrimLeft = new int[156];
		anInt1054 = -1;
		stillGraphicList = new Deque();
		compassTrimRight = new int[33];
		iComponent = new Interface();
		mapScenes = new IndexedSprite[100];
		anIntArray1065 = new int[7];
		anIntArray1072 = new int[1000];
		anIntArray1073 = new int[1000];
		aBoolean1080 = false;
		friendsList = new String[200];
		inputStream = Packet.create();
		expectedCRCs = new int[9];
		menuActionCmd2 = new int[500];
		menuActionCmd3 = new int[500];
		menuActionID = new int[500];
		menuActionCmd1 = new int[500];
		headIcons_prayer = new Sprite[20];
		headIcons_pk = new Sprite[20];
		headIcons_hint = new Sprite[20];
		inventoryAltered = false;
		messagePromptTitle = "";
		atPlayerActions = new String[5];
		atPlayerArray = new boolean[5];
		anIntArrayArrayArray1129 = new int[4][13][13];
		anInt1132 = 2;
		aClass30_Sub2_Sub1_Sub1Array1140 = new Sprite[1000];
		aBoolean1141 = false;
		aBoolean1149 = false;
		crosses = new Sprite[8];
		musicEnabled = true;
		drawInventoryRequest = false;
		Client.loggedIn = false;
		canMute = false;
		aBoolean1159 = false;
		aBoolean1160 = false;
		anInt1171 = 1;
		myUsername = "";
		myPassword = "";
		genericLoadingError = false;
		reportAbuseInterfaceID = -1;
		aClass19_1179 = new Deque();
		anInt1184 = 128;
		invOverlayInterfaceID = -1;
		outputStream = Packet.create();
		menuActionName = new String[500];
		anIntArray1203 = new int[5];
		anIntArray1207 = new int[50];
		anInt1210 = 2;
		scrollerHeight = 78;
		promptInput = "";
		modIcons = new IndexedSprite[2];
		tabID = 3;
		Client.inputTaken = false;
		songChanging = true;
		miniMapTrimRight = new int[156];
		collisionMap = new CollisionMap[4];
		anIntArray1240 = new int[100];
		anIntArray1241 = new int[50];
		aBoolean1242 = false;
		anIntArray1250 = new int[50];
		rsAlreadyLoaded = false;
		welcomeScreenRaised = false;
		messagePromptRaised = false;
		loginMessage1 = "";
		loginMessage2 = "";
		backDialogID = -1;
		anInt1279 = 2;
		bigX = new int[4000];
		bigY = new int[4000];
		anInt1289 = -1;
	}
}
